Files
Varaverk/unRAID Essentials/mover-stop.sh
T

64 lines
2.1 KiB
Bash

#!/bin/bash
set -e
# ----------------------------------------------------------------------------------------------
# --------------------------- Mover Stop Script for Unraid -------------------------------------
# ----------------------------------------------------------------------------------------------
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
# ----------------------------------------------------------------------------------------------
#
# User variables can be adjusted in Master.conf
#
# Scripts now just contain runtime logic
#
# 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, Please adjust in Master.conf as needed -----------------
# ----------------------------------------------------------------------------------------------
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 "$@"
# Optional: MOVER_STOP_TIMEOUT in seconds (default from Master.conf or 30s)
MOVER_STOP_TIMEOUT=${MOVER_STOP_TIMEOUT:-30}
validate_int MOVER_STOP_TIMEOUT "$MOVER_STOP_TIMEOUT"
# Functions
notify_users() {
wall "⚠️ Unraid Mover will stop in ${MOVER_STOP_TIMEOUT} second(s)."
}
check_mover_running() {
pgrep -f "emhttp.*Mover" >/dev/null 2>&1
}
stop_mover() {
if [ "$DRY_RUN" = true ]; then
echo "[DRY-RUN] Would stop the Mover process"
else
echo "Stopping Mover..."
# Unraid native way: kill the mover process gracefully
pkill -f "emhttp.*Mover"
fi
}
# MAIN
echo "==== Mover Stop Script Started: $(date) ===="
if check_mover_running; then
notify_users
sleep "$MOVER_STOP_TIMEOUT"
stop_mover
echo "Mover stopped."
else
echo "Mover is not running."
fi