aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCullum Smith <cullum@sacredheartsc.com>2024-07-14 21:48:37 -0400
committerCullum Smith <cullum@sacredheartsc.com>2024-07-14 21:48:37 -0400
commit89cdd1c872694797a8f6f0185be2b2cd3467bfcc (patch)
treeb62d710a7ac7edb210b7a72be7582d8579e469b9
parent6febd59c9a36f6f35057a6c80d59825d92c7377d (diff)
downloadinfrastructure-89cdd1c872694797a8f6f0185be2b2cd3467bfcc.tar.gz
add default nameservers for jailctl
-rw-r--r--files/usr/local/etc/jailctl.conf.freebsd_hypervisor1
-rw-r--r--files/usr/local/sbin/jailctl.freebsd_hypervisor8
2 files changed, 5 insertions, 4 deletions
diff --git a/files/usr/local/etc/jailctl.conf.freebsd_hypervisor b/files/usr/local/etc/jailctl.conf.freebsd_hypervisor
index 02b6065..a3a37dc 100644
--- a/files/usr/local/etc/jailctl.conf.freebsd_hypervisor
+++ b/files/usr/local/etc/jailctl.conf.freebsd_hypervisor
@@ -5,6 +5,7 @@ JAIL_DATASET='${hypervisor_jail_dataset}'
TRUNK_INTERFACE='${hypervisor_trunk_interface}'
DEFAULT_DOMAIN='${domain}'
+DEFAULT_NAMESERVERS='${resolvers:-1.1.1.1}'
DEFAULT_VLAN='${hypervisor_default_vlan}'
DEFAULT_NETMASK='$(prefix2netmask "$hypervisor_default_prefix")'
DEFAULT_OS_QUOTA='${hypervisor_default_os_quota}'
diff --git a/files/usr/local/sbin/jailctl.freebsd_hypervisor b/files/usr/local/sbin/jailctl.freebsd_hypervisor
index 3698aa4..03ed563 100644
--- a/files/usr/local/sbin/jailctl.freebsd_hypervisor
+++ b/files/usr/local/sbin/jailctl.freebsd_hypervisor
@@ -171,6 +171,8 @@ Options:
: ${gateway:="${ip%.*}.1"}
fi
+ : ${nameservers:="$DEFAULT_NAMESERVERS"}
+
[ $# -lt 1 ] && cmd::usage 'NAME not specified'
[ $# -lt 2 ] && cmd::usage 'TEMPLATE not specified'
[ $# -gt 2 ] && cmd::usage 'too many arguments'
@@ -205,10 +207,8 @@ Options:
cp -v /etc/localtime "${JAIL_HOME}/${name}/os/etc/localtime"
# Generate /etc/resolv.conf in the jail (word-splitting intentional).
- if [ -n "${nameservers:-} "]; then
- printf 'nameserver %s\n' $nameservers >> "${JAIL_HOME}/${name}/os/etc/resolv.conf"
- printf 'search %s\n' "${searchdomains:-$domain}" >> "${JAIL_HOME}/${name}/os/etc/resolv.conf"
- fi
+ printf 'nameserver %s\n' $nameservers >> "${JAIL_HOME}/${name}/os/etc/resolv.conf"
+ printf 'search %s\n' "${searchdomains:-$domain}" >> "${JAIL_HOME}/${name}/os/etc/resolv.conf"
# Get the jail's virtual interface name.
local epair_name