diff options
author | Cullum Smith <cullum@sacredheartsc.com> | 2024-07-14 21:42:33 -0400 |
---|---|---|
committer | Cullum Smith <cullum@sacredheartsc.com> | 2024-07-14 21:42:33 -0400 |
commit | 6febd59c9a36f6f35057a6c80d59825d92c7377d (patch) | |
tree | 745585c9e1f8b6ba0180e3b891d6dd3fd2c27166 /files | |
parent | 241833b7f320e7fca84ba226f1ecbb0c963534f7 (diff) | |
download | infrastructure-6febd59c9a36f6f35057a6c80d59825d92c7377d.tar.gz |
make jailctl more ergonomic
Diffstat (limited to 'files')
-rw-r--r-- | files/usr/local/sbin/jailctl.freebsd_hypervisor | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/files/usr/local/sbin/jailctl.freebsd_hypervisor b/files/usr/local/sbin/jailctl.freebsd_hypervisor index 05c0158..3698aa4 100644 --- a/files/usr/local/sbin/jailctl.freebsd_hypervisor +++ b/files/usr/local/sbin/jailctl.freebsd_hypervisor @@ -132,6 +132,7 @@ Options: devfs_ruleset=$DEFAULT_DEVFS_RULESET \ domain=$DEFAULT_DOMAIN \ gateway \ + jail_opts \ ip \ memlimit \ nameservers \ @@ -143,12 +144,13 @@ Options: vlan=$DEFAULT_VLAN \ opt - while getopts :a:bc:d:g:hk:m:n:q:Q:r:s:v: opt; do + while getopts :a:bc:d:e:g:hk:m:n:q:Q:r:s:v: opt; do case $opt in a) ip=$OPTARG ;; b) bpf_enabled=true ;; c) cpuset=$OPTARG ;; d) domain=$OPTARG ;; + e) jail_opts="${jail_opts:-}"$'\n'" ${OPTARG};" ;; g) gateway=$OPTARG ;; h) cmd::help ;; k) sshkey=$OPTARG ;; @@ -165,6 +167,10 @@ Options: done shift $((OPTIND - 1)) + if [ -n "${ip:-}" ]; then + : ${gateway:="${ip%.*}.1"} + fi + [ $# -lt 1 ] && cmd::usage 'NAME not specified' [ $# -lt 2 ] && cmd::usage 'TEMPLATE not specified' [ $# -gt 2 ] && cmd::usage 'too many arguments' @@ -199,8 +205,10 @@ Options: cp -v /etc/localtime "${JAIL_HOME}/${name}/os/etc/localtime" # Generate /etc/resolv.conf in the jail (word-splitting intentional). - [ -n "${nameservers:-}" ] && printf 'nameserver %s\n' $nameservers >> "${JAIL_HOME}/${name}/os/etc/resolv.conf" - [ -n "${searchdomains:-}" ] && printf 'search %s\n' "$searchdomains" >> "${JAIL_HOME}/${name}/os/etc/resolv.conf" + 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 # Get the jail's virtual interface name. local epair_name @@ -272,6 +280,8 @@ ${name} { vnet; vnet.interface = "ej_${epair_name}"; +${jail_opts:-} + EOF ln -sv "$jailcfg" "/etc/jail.conf.d/${name}.conf" |