Skip to content

Commit 0c7a0be

Browse files
committed
Allow starting jails with ip[46] set to inherit
Either or both ip4 and ip6 can be set to inherit. For example I have used the following config: ``` interface = vtnet0; ip4 = inherit; ip6 = new; ip6.addr = 2a01:xxxx:xxxx:xxx::1; ```
1 parent 78c77b7 commit 0c7a0be

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

usr/local/share/bastille/start.sh

+26-7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ usage() {
3535
error_exit "Usage: bastille start TARGET"
3636
}
3737

38+
# indicate if an IP configurtaion value (e.g. a value given for ip4 or ip6)
39+
# requires extra configuration external to the jail
40+
#
41+
# success if it does, failure if it does not
42+
ip_require_config() {
43+
44+
case "${1}" in
45+
disable|inherit|"not set")
46+
return 1
47+
;;
48+
esac
49+
50+
return 0
51+
}
52+
3853
# Handle special-case commands first.
3954
case "$1" in
4055
help|-h|--help)
@@ -69,14 +84,18 @@ for _jail in ${JAILS}; do
6984

7085
## test if not running
7186
elif [ ! "$(/usr/sbin/jls name | awk "/^${_jail}$/")" ]; then
72-
# Verify that the configured interface exists. -- cwells
73-
if [ "$(bastille config $_jail get vnet)" != 'enabled' ]; then
74-
_interface=$(bastille config $_jail get interface)
75-
if ! ifconfig | grep "^${_interface}:" >/dev/null; then
76-
error_notify "Error: ${_interface} interface does not exist."
77-
continue
87+
## if networking is entirely inherited we can skip any setup
88+
_ip4=$(bastille config $_jail get ip4)
89+
_ip6=$(bastille config $_jail get ip6)
90+
if ip_require_config "${_ip4}" || ip_require_config "${_ip6}"; then
91+
# Verify that the configured interface exists. -- cwells
92+
if [ "$(bastille config $_jail get vnet)" != 'enabled' ]; then
93+
_interface=$(bastille config $_jail get interface)
94+
if ! ifconfig | grep "^${_interface}:" >/dev/null; then
95+
error_notify "Error: ${_interface} interface does not exist."
96+
continue
97+
fi
7898
fi
79-
fi
8099

81100
## warn if matching configured (but not online) ip4.addr, ignore if there's no ip4.addr entry
82101
ip=$(bastille config "${_jail}" get ip4.addr)

0 commit comments

Comments
 (0)