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