Restructured to add common functions and added a server reboot script
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
#----------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
# This is the Unattended Reboot Script for Unraid
|
||||
#
|
||||
# User variables can be adjusted in Master.conf
|
||||
# This script is using the SLEEP Variable from Master.conf for the delay before reboot
|
||||
#
|
||||
# This new setup allows for profiles and arguments to use the core script
|
||||
# Use arguments in unRAID User Plugin for directory
|
||||
# Example: /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh --dry-run
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
#---------------End Of User Variables ----------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# Load central config
|
||||
load_master_conf
|
||||
|
||||
# Parse CLI args (flags + VAR=value)
|
||||
parse_args "$@"
|
||||
|
||||
# Validate SLEEP
|
||||
validate_int SLEEP "$SLEEP"
|
||||
|
||||
# --- Functions
|
||||
|
||||
notify_users() {
|
||||
wall "⚠️ Unraid server will reboot in ${SLEEP} second(s). Save your work."
|
||||
}
|
||||
|
||||
# --- MAIN
|
||||
|
||||
echo "==== Scheduled Reboot Script Started: $(date) ===="
|
||||
|
||||
# Optional warning before reboot
|
||||
if [ "$SLEEP" -gt 0 ]; then
|
||||
notify_users
|
||||
sleep "$SLEEP"
|
||||
fi
|
||||
|
||||
# Stop Docker
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would stop Docker: /etc/rc.d/rc.docker stop"
|
||||
else
|
||||
echo "Stopping Docker..."
|
||||
/etc/rc.d/rc.docker stop
|
||||
fi
|
||||
|
||||
# Stop VM Manager
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would stop VM Manager: /etc/rc.d/rc.libvirt stop"
|
||||
else
|
||||
echo "Stopping VM Manager..."
|
||||
/etc/rc.d/rc.libvirt stop
|
||||
fi
|
||||
|
||||
# Sync disks
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would sync disks"
|
||||
else
|
||||
echo "Syncing disks..."
|
||||
sync
|
||||
fi
|
||||
|
||||
# Reboot system
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would reboot system: /sbin/reboot"
|
||||
else
|
||||
echo "Rebooting system..."
|
||||
/sbin/reboot
|
||||
fi
|
||||
Reference in New Issue
Block a user