loglevel errors should get shown always, startupcommand is shown with debug level >=2
This commit is contained in:
parent
8498ada9bf
commit
9e31a8d419
29
nlvmi
29
nlvmi
|
@ -2,7 +2,7 @@
|
|||
|
||||
#getting the config
|
||||
source /etc/nlvmi/nlvmi.conf
|
||||
if [ $LOGLEVEL -gt "1" ]; then echo "configuration loaded"; fi
|
||||
if [ $LOGLEVEL -gt "2" ]; then echo "configuration loaded"; fi
|
||||
|
||||
#check if we are root and wrap if we are not
|
||||
U=`/usr/bin/whoami`
|
||||
|
@ -137,7 +137,7 @@ function vmautostart {
|
|||
#start single VM
|
||||
function vmstart {
|
||||
if [ -z $1 ]; then echo "function start needs an id!"; exit 1; fi
|
||||
if [ $LOGLEVEL -gt "1" ]; then echo "startvm function entered for vmid $1"; fi
|
||||
if [ $LOGLEVEL -gt "2" ]; then echo "startvm function entered for vmid $1"; fi
|
||||
sqlite3 $SQLITEFILE "SELECT * FROM vms LEFT JOIN servers on vms.server = servers.hostname WHERE vms.id=$1" | while read line; do
|
||||
IFS='|' read -r -a array <<< "$line"
|
||||
#prepare tmpfile
|
||||
|
@ -161,15 +161,15 @@ 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]} && ifconfig ${array[20]} up" >>$TMPF; 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[21]} ]; then MACADDR1="-net nic,macaddr=${array[21]},model=virtio,netdev=net0"; fi
|
||||
if [ ! -z ${array[22]} ]; then BRDEV1="${array[22]}"; echo "/sbin/brctl addif ${array[22]} ${array[20]}" >>$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]} && ifconfig ${array[23]} up" >>$TMPF; 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[24]} ]; then MACADDR2="-net nic,macaddr=${array[24]},model=virtio,netdev=net1"; fi
|
||||
if [ ! -z ${array[25]} ]; then BRDEV2="${array[25]}"; echo "/sbin/brctl addif ${array[25]} ${array[23]}" >>$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]} && ifconfig ${array[26]} up" >>$TMPF; 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[27]} ]; then MACADDR3="-net nic,macaddr=${array[27]},model=virtio,netdev=net2"; fi
|
||||
if [ ! -z ${array[28]} ]; then BRDEV3="${array[28]}"; echo "/sbin/brctl addif ${array[28]} ${array[26]}" >>$TMPF; 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
|
||||
if [ ! -z ${array[31]} ]; then VNCPASS=",password"; fi
|
||||
if [ ! -z ${array[29]} ]; then VNCPORT="-vnc :${array[29]}$WEBSOCK$VNCPASS"; fi
|
||||
|
@ -187,13 +187,16 @@ function vmstart {
|
|||
su nlvmi -c "ssh ${array[35]} \"rm /home/nlvmi/start*-${array[1]}.tmp*\""
|
||||
mv $TMPFR $TMPF
|
||||
su nlvmi -c "scp $TMPF* ${array[35]}:/home/nlvmi/"
|
||||
su nlvmi -c "ssh ${array[35]} \"/usr/bin/nlvmi remote $TMPF run\""
|
||||
OUT=`su nlvmi -c "ssh ${array[35]} \"/usr/bin/nlvmi remote $TMPF run\"" 2>&1`
|
||||
echo $OUT
|
||||
if [ ${array[12]} == "0" ]; then
|
||||
su nlvmi -c "ssh ${array[35]} \"rm $TMPF $TMPF.sha512\""
|
||||
echo $OUT
|
||||
fi
|
||||
rm $TMPF $TMPF.sha512
|
||||
else
|
||||
/bin/bash $TMPF
|
||||
OUT=`/bin/bash $TMPF 2>&1`
|
||||
echo $OUT
|
||||
if [ ${array[12]} == "0" ]; then
|
||||
rm $TMPF
|
||||
fi
|
||||
|
@ -215,7 +218,7 @@ function vmstart {
|
|||
|
||||
#stop VM
|
||||
function vmstop {
|
||||
if [ $LOGLEVEL -gt "1" ]; then echo "stopvm function entered for VM $1"; fi
|
||||
if [ $LOGLEVEL -gt "2" ]; then echo "stopvm function entered for VM $1"; fi
|
||||
sqlite3 $SQLITEFILE "SELECT vms.id AS vid,vmname,connectstring FROM vms LEFT JOIN servers ON vms.server = servers.hostname WHERE vmname='$1'" | while read line; do
|
||||
IFS='|' read -r -a array <<< "$line"
|
||||
if [ -z ${array[2]} ]; then
|
||||
|
@ -319,7 +322,7 @@ if [ $# -gt 0 ]; then
|
|||
elif [ $1 == "start" ]; then
|
||||
if [ -z $2 ]; then echo "start needs a vmname!"; exit 1; fi
|
||||
VMFOUND="no"
|
||||
if [ $LOGLEVEL -gt "1" ]; then echo "searching for vmname $2"; fi
|
||||
if [ $LOGLEVEL -gt "2" ]; then echo "searching for vmname $2"; fi
|
||||
sqlite3 $SQLITEFILE "SELECT id FROM vms WHERE vmname='$2'" | (while read line; do
|
||||
IFS='|' read -r -a arrays <<< "$line"
|
||||
declare VMFOUND="yes"
|
||||
|
@ -330,7 +333,7 @@ if [ $# -gt 0 ]; then
|
|||
elif [ $1 == "stop" ]; then
|
||||
if [ -z $2 ]; then echo "stop needs a vmname!"; exit 1; fi
|
||||
VMFOUND="no"
|
||||
if [ $LOGLEVEL -gt "1" ]; then echo "searching for vmname $2"; fi
|
||||
if [ $LOGLEVEL -gt "2" ]; then echo "searching for vmname $2"; fi
|
||||
sqlite3 $SQLITEFILE "SELECT id FROM vms WHERE vmname='$2'" | (while read line; do
|
||||
IFS='|' read -r -a arrays <<< "$line"
|
||||
declare VMFOUND="yes"
|
||||
|
|
Loading…
Reference in New Issue