mirror of
https://codeberg.org/scip/jaildk.git
synced 2025-12-16 20:21:05 +01:00
- (re) allow login :)
- added error checking to vnet command
This commit is contained in:
61
jaildk
61
jaildk
@@ -2018,42 +2018,43 @@ jaildk_vnet() {
|
||||
|
||||
vnethost="ep${jail}.h"
|
||||
vnetjail="ep${jail}.j"
|
||||
epairA=''
|
||||
epairB=''
|
||||
|
||||
case $mode in
|
||||
start)
|
||||
# FIXME: add error handling!
|
||||
epairA=$(ifconfig epair create)
|
||||
epairB="${epairA%?}b"
|
||||
if ! ifconfig $vnethost > /dev/null 2>&1; then
|
||||
# setup epair
|
||||
epairA=$(ifconfig epair create)
|
||||
epairB="${epairA%?}b"
|
||||
|
||||
ex ifconfig $epairA name $vnethost
|
||||
ex ifconfig $epairB name $vnetjail
|
||||
ex ifconfig $epairA name $vnethost || true
|
||||
ex ifconfig $epairB name $vnetjail || true
|
||||
|
||||
# if vm-bhyve is enabled we could use this as well:
|
||||
#vm switch add $BRIDGE $vnethost
|
||||
|
||||
# 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
|
||||
ex ifconfig $vnetjail up
|
||||
ex ifconfig $vnethost up
|
||||
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
|
||||
ex jexec $jail ifconfig $vnetjail inet6 $ip6
|
||||
ex jexec $jail route -6 add default $gw6
|
||||
if ! jexec $jail ifconfig $vnetjail inet6 | grep -v fe80 | grep prefixlen > /dev/null 2>&1; then
|
||||
# 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
|
||||
;;
|
||||
stop)
|
||||
@@ -2229,7 +2230,7 @@ case $runner in
|
||||
jaildk_$runner $*
|
||||
;;
|
||||
login)
|
||||
jaildk_login
|
||||
jaildk_login $*
|
||||
;;
|
||||
help)
|
||||
usage_help $*
|
||||
|
||||
Reference in New Issue
Block a user