[Proxmox Timed Shutdown]
- Added ability to cancel session shutdown depending on presence of environment variable.
This commit is contained in:
+13
-6
@@ -1,10 +1,17 @@
|
||||
#!/bin/bash
|
||||
CURRENT_TIME=$(date +%H:%M)
|
||||
SCH_SHUTDOWN_TIME="01:00"
|
||||
QUERY_BACKUP_TASK=$( ps -ef | grep vzdump | wc -l)
|
||||
|
||||
if [[ $CURRENT_TIME > "00:00" ]] && [[ $CURRENT_TIME < "08:30" ]]; then
|
||||
echo "Triggering scheduled post-backup shutdown at $SCH_SHUTDOWN_TIME"
|
||||
shutdown -P $SCH_SHUTDOWN_TIME
|
||||
if ! [ -z $C_SHUTDOWN ]; then
|
||||
if [ $C_SHUTDOWN -eq "1" ]; then
|
||||
echo "Shutdown has been cancelled due to ENV"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $QUERY_BACKUP_TASK -eq 1 ]; then
|
||||
echo "Triggering scheduled post-backup shutdown"
|
||||
/usr/sbin/shutdown -h now
|
||||
else
|
||||
echo "Automatic shutdown not triggered due to current time"
|
||||
echo "Automatic shutdown not triggered due to concurrent backup task"
|
||||
exit 2
|
||||
fi
|
||||
Reference in New Issue
Block a user