- (re) allow login :)

- added error checking to vnet command
This commit is contained in:
Thomas von Dein
2021-07-04 12:49:34 +02:00
parent 8c760ef130
commit 6b4f80cf55

61
jaildk
View File

@@ -2018,42 +2018,43 @@ jaildk_vnet() {
vnethost="ep${jail}.h" vnethost="ep${jail}.h"
vnetjail="ep${jail}.j" vnetjail="ep${jail}.j"
epairA=''
epairB=''
case $mode in case $mode in
start) start)
# FIXME: add error handling! if ! ifconfig $vnethost > /dev/null 2>&1; then
epairA=$(ifconfig epair create) # setup epair
epairB="${epairA%?}b" epairA=$(ifconfig epair create)
epairB="${epairA%?}b"
ex ifconfig $epairA name $vnethost ex ifconfig $epairA name $vnethost || true
ex ifconfig $epairB name $vnetjail ex ifconfig $epairB name $vnetjail || true
# if vm-bhyve is enabled we could use this as well: ex ifconfig $vnetjail up
#vm switch add $BRIDGE $vnethost ex ifconfig $vnethost up
# make sure
ex ifconfig $vnetjail up
ex ifconfig $vnethost up
# add the host to the bridge
ex ifconfig $BRIDGE addm $vnethost up
# add the jail to the bridge (gets invisible from host)
ex ifconfig $vnetjail vnet $jail
# configure the jail network stack inside the jail
ex jexec $jail ifconfig $vnetjail $ip up
ex jexec $jail route add default $gw
if test -n "$ip6" -a -n "$gw6"; then
ex jexec $jail ifconfig $vnetjail inet6 $ip6
ex jexec $jail route -6 add default $gw6
fi fi
;;
start6) if ! ifconfig $BRIDGE | egrep member:.$vnethost > /dev/null 2>&1; then
# add the host to the bridge
ex ifconfig $BRIDGE addm $vnethost up || true
# add the jail to the bridge (gets invisible from host)
ex ifconfig $vnetjail vnet $jail || true
fi
if ! jexec $jail ifconfig $vnetjail inet | grep netmask > /dev/null 2>&1; then
# configure the jail v4 network stack inside the jail
ex jexec $jail ifconfig $vnetjail $ip up || true
ex jexec $jail route add default $gw || true
fi
if test -n "$ip6" -a -n "$gw6"; then if test -n "$ip6" -a -n "$gw6"; then
ex jexec $jail ifconfig $vnetjail inet6 $ip6 if ! jexec $jail ifconfig $vnetjail inet6 | grep -v fe80 | grep prefixlen > /dev/null 2>&1; then
ex jexec $jail route -6 add default $gw6 # configure the jail v4 network stack inside the jail
ex jexec $jail ifconfig $vnetjail inet6 $ip6 || true
ex jexec $jail route -6 add default $gw6 || true
fi
fi fi
;; ;;
stop) stop)
@@ -2229,7 +2230,7 @@ case $runner in
jaildk_$runner $* jaildk_$runner $*
;; ;;
login) login)
jaildk_login jaildk_login $*
;; ;;
help) help)
usage_help $* usage_help $*