minor fixes debug info to dry-run

This commit is contained in:
masterdraco 2025-02-23 23:18:40 +01:00
parent 48af3f3a42
commit d40779e97a

View File

@ -1,5 +1,32 @@
#!/bin/bash
# Torrent Mover v5.1 - Numeric Handling Fix
# Torrent Mover v5.3 - Singleton Implementation
# Singleton pattern
LOCK_FILE="/var/lock/torrent-mover.lock"
MAX_AGE=300 # 5 minutes in seconds
# Check for existing lock
if [ -f "${LOCK_FILE}" ]; then
PID=$(cat "${LOCK_FILE}")
# Check if process exists
if ps -p "${PID}" > /dev/null 2>&1; then
echo "Already running (PID: ${PID}), exiting."
exit 1
else
# Check lock file age
if [ $(($(date +%s) - $(date -r "${LOCK_FILE}" +%s))) -lt ${MAX_AGE} ]; then
echo "Recent crash detected, waiting..."
exit 1
fi
echo "Removing stale lock (PID: ${PID})"
rm -f "${LOCK_FILE}"
fi
fi
# Create new lock
echo $$ > "${LOCK_FILE}"
trap 'rm -f "${LOCK_FILE}"' EXIT TERM INT
set -o errexit
set -o nounset