Files

27 lines
895 B
Bash
Raw Permalink Normal View History

2026-04-14 23:55:21 +02:00
#!/bin/bash
echo "Check for Serverhost state"
SHUTDOWN=true
if [ $(cat /home/lucas/.auto_shutdown | grep yes | wc -l) -lt 1 ] ; then
echo "Auto Shutdown disabled"
SHUTDOWN=false
fi
if [ $(ps -elf | grep -e 'backup_all\.sh' | grep -v grep | wc -l) -ge 1 ]; then
echo "Backup in progress"
SHUTDOWN=false
fi
if [ $(ps -elf | grep -e 'upgrade\.sh' | grep -v grep | wc -l) -ge 1 ]; then
echo "Upgrade in progress"
SHUTDOWN=false
fi
if $SHUTDOWN; then
echo "Shutdown serverhost"
sudo /sbin/shutdown -P 1 +6
ssh -o ConnectTimeout=4 -p 1504 lucas@quiethost 'notify-send "Shutdown SUCCESSFUL for Serverhost"'
timeout 2s notify-send "Shutdown SUCESSFULL for Serverhost"
else
echo "Skip shutdown"
ssh -o ConnectTimeout=4 -p 1504 lucas@quiethost 'notify-send "Shutdown FAILED for Serverhost"'
timeout 2s notify-send "Shutdown FAILED for Serverhost"
fi