centos has no tunctl, using ip instead to create tap devices

This commit is contained in:
nativemad 2018-11-13 12:53:59 +01:00
parent 9e31a8d419
commit 7d43ab1428
1 changed files with 3 additions and 3 deletions

6
nlvmi
View File

@ -161,13 +161,13 @@ function vmstart {
if [ ! -z ${array[17]} ]; then DRIVE3="-drive file=${array[17]}"; echo "chown ${array[2]}:nlvmi ${array[17]}" >>$TMPF; fi
if [ ! -z ${array[18]} ]; then FORMAT3=",format=${array[18]},if=virtio"; fi
if [ ! -z ${array[19]} ]; then CDROM="-cdrom ${array[19]}"; fi
if [ ! -z ${array[20]} ]; then TAPDEV1="-netdev tap,ifname=${array[20]},script=no,id=net0"; echo "tunctl -t ${array[20]} -u ${array[2]} >/dev/null && ifconfig ${array[20]} up" >>$TMPF; fi
if [ ! -z ${array[20]} ]; then TAPDEV1="-netdev tap,ifname=${array[20]},script=no,id=net0"; echo "which tunctl && tunctl -t ${array[20]} -u ${array[2]} >/dev/null || ip tuntap add ${array[20]} mode tap user ${array[2]}; ifconfig ${array[20]} up" >>$TMPF; fi
if [ ! -z ${array[21]} ]; then MACADDR1="-net nic,macaddr=${array[21]},model=virtio,netdev=net0"; fi
if [ ! -z ${array[22]} ]; then BRDEV1="${array[22]}"; echo "if [ -L /sys/devices/virtual/net/${array[20]}/master ]; then OLDBR=\`readlink -f /sys/devices/virtual/net/${array[20]}/master | rev | cut -d "/" -f1 | rev\`; brctl delif \$OLDBR ${array[20]}; fi; /sbin/brctl addif ${array[22]} ${array[20]} >/dev/null" >>$TMPF; fi
if [ ! -z ${array[23]} ]; then TAPDEV2="-netdev tap,ifname=${array[23]},script=no,id=net1"; echo "tunctl -t ${array[23]} -u ${array[2]} >/dev/null && ifconfig ${array[23]} up" >>$TMPF; fi
if [ ! -z ${array[23]} ]; then TAPDEV2="-netdev tap,ifname=${array[23]},script=no,id=net1"; echo "which tunctl && tunctl -t ${array[23]} -u ${array[2]} >/dev/null || ip tuntap add ${array[23]} mode tap user ${array[2]}; ifconfig ${array[23]} up" >>$TMPF; fi
if [ ! -z ${array[24]} ]; then MACADDR2="-net nic,macaddr=${array[24]},model=virtio,netdev=net1"; fi
if [ ! -z ${array[25]} ]; then BRDEV2="${array[25]}"; echo "if [ -L /sys/devices/virtual/net/${array[23]}/master ]; then OLDBR=\`readlink -f /sys/devices/virtual/net/${array[23]}/master | rev | cut -d "/" -f1 | rev\`; brctl delif \$OLDBR ${array[23]}; fi; /sbin/brctl addif ${array[25]} ${array[23]} >/dev/null" >>$TMPF; fi
if [ ! -z ${array[26]} ]; then TAPDEV3="-netdev tap,ifname=${array[26]},script=no,id=net2"; echo "tunctl -t ${array[26]} -u ${array[2]} >/dev/null && ifconfig ${array[26]} up" >>$TMPF; fi
if [ ! -z ${array[26]} ]; then TAPDEV3="-netdev tap,ifname=${array[26]},script=no,id=net2"; echo "which tunctl && tunctl -t ${array[26]} -u ${array[2]} >/dev/null || ip tuntap add ${array[26]} mode tap user ${array[2]}; ifconfig ${array[26]} up" >>$TMPF; fi
if [ ! -z ${array[27]} ]; then MACADDR3="-net nic,macaddr=${array[27]},model=virtio,netdev=net2"; fi
if [ ! -z ${array[28]} ]; then BRDEV3="${array[28]}"; echo "if [ -L /sys/devices/virtual/net/${array[26]}/master ]; then OLDBR=\`readlink -f /sys/devices/virtual/net/${array[26]}/master | rev | cut -d "/" -f1 | rev\`; brctl delif \$OLDBR ${array[26]}; fi; /sbin/brctl addif ${array[28]} ${array[26]} >/dev/null" >>$TMPF; fi
if [ ! -z ${array[30]} ]; then WPORT=$((${array[30]} + 5700)); WEBSOCK=",websocket=$WPORT"; else WEBSOCK=""; fi