Update file watchdog.sh
This commit is contained in:
parent
e5f10f0374
commit
7bdb746d19
18
watchdog.sh
18
watchdog.sh
@ -10,32 +10,34 @@ fi
|
|||||||
|
|
||||||
#------------------------------------------------
|
#------------------------------------------------
|
||||||
# CONSTS
|
# CONSTS
|
||||||
QMLIST="$(qm list | tail -n +2)"
|
VMID="$1"
|
||||||
VMID=$1
|
QMSTAT="$(/usr/sbin/qm status $VMID )" > /dev/nul> /dev/null0
|
||||||
|
|
||||||
#------------------------------------------------
|
#------------------------------------------------
|
||||||
# CODE
|
# CODE
|
||||||
|
|
||||||
# check if container exists
|
# check if container exists
|
||||||
if ! echo "$QMLIST" | grep -q " $VMID "
|
if echo $QMSTAT | grep "not exist"
|
||||||
then
|
then
|
||||||
printf "\nNo such VM!\n"
|
printf "\nNo such VM!\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VMSTATE=$(echo "$QMLIST" | grep " $VMID " | awk '{print $3}')
|
|
||||||
|
VMSTATE=$(echo "$QMSTAT" | awk '{print $2}')
|
||||||
|
#echo $VMSTATE
|
||||||
|
|
||||||
case $VMSTATE in
|
case $VMSTATE in
|
||||||
|
|
||||||
"running")
|
"running")
|
||||||
printf "VM %s" "$VMID" "allready running."
|
#printf "VM %s" "$VMID" "allready running."
|
||||||
echo ""
|
#echo ""
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"stopped")
|
"stopped")
|
||||||
printf "Starting VM %s" "$VMID""."
|
printf "\nStarting VM %s" "$VMID\n"
|
||||||
echo "" # To lazy to fix output spacing
|
#echo "" # To lazy to fix output spacing
|
||||||
qm start "$VMID"
|
qm start "$VMID"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user