diff --git a/scripts/mkjail.sh b/scripts/mkjail.sh index 2f76e14..8942a6f 100755 --- a/scripts/mkjail.sh +++ b/scripts/mkjail.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + if [ -f "/usr/local/etc/reggae.conf" ]; then . "/usr/local/etc/reggae.conf" fi @@ -173,9 +175,8 @@ EOF -e "s;MAC;${MAC};g" \ "${SCRIPT_DIR}/../templates/base-jail.conf" >>"/etc/jail.conf.d/${NAME}.conf" echo -e "${OPTIONS}\n}" >>"/etc/jail.conf.d/${NAME}.conf" - sysrc -R "${BSDINSTALL_CHROOT}" ifconfig_eth0="ether ${MAC}" if [ "${USE_IPV4}" = "yes" ]; then - sysrc -R "${BSDINSTALL_CHROOT}" ifconfig_eth0+="DHCP" + sysrc -R "${BSDINSTALL_CHROOT}" ifconfig_eth0="DHCP" fi if [ "${USE_IPV6}" = "yes" ]; then sysrc -R "${BSDINSTALL_CHROOT}" ifconfig_eth0_ipv6="inet6 -ifdisabled accept_rtadv auto_linklocal" diff --git a/templates/base-jail.conf b/templates/base-jail.conf index fe510bb..8797c62 100644 --- a/templates/base-jail.conf +++ b/templates/base-jail.conf @@ -6,17 +6,17 @@ mount.devfs; host.domainname = "HOST"; host.hostname = "${name}.${host.domainname}"; - vnet.interface = "epair${id}a"; - $host_interface = "epair${id}b"; + $host_interface = "epair${id}a"; + vnet.interface = "epair${id}b"; devfs_ruleset = 8; allow.raw_sockets; exec.clean; - exec.prepare = "ifconfig ${vnet.interface} && ifconfig ${host_interface} destroy || true"; - exec.prestart = "ifconfig epair${id} create ether ${mac} group $(echo ${name} | cut -b 1-15) up || (ifconfig ${vnet.interface} destroy && false)"; - exec.prestart += "ifconfig ${host_interface} up"; + exec.prepare = "ifconfig ${host_interface} && ifconfig ${host_interface} destroy || true"; + exec.prestart = "ifconfig epair${id} create group $(echo ${name} | cut -b 1-15) up || (ifconfig ${host_interface} destroy && false)"; exec.prestart += "ifconfig jails addm ${host_interface}"; exec.start = "ifconfig ${vnet.interface} name eth0"; + exec.start += "ifconfig eth0 ether ${mac}"; exec.start += "service dhclient start eth0"; exec.start += "/bin/sh /etc/rc"; exec.stop = "/bin/sh /etc/rc.shutdown";