Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Config
- THRESHOLD=70
- CACHE_PATH="/mnt/cache"
- # Get current time in minutes since midnight
- CURRENT_MIN=$(date +%H:%M | awk -F: '{ print ($1 * 60) + $2 }')
- # Define time window: 1:00am to 1:30am = 60 to 90 minutes
- RUN_WINDOW_START=60
- RUN_WINDOW_END=90
- # Get current cache usage as integer
- USAGE=$(df "$CACHE_PATH" | awk 'NR==2 {gsub("%",""); print $5}')
- # Determine if we should run the mover
- if [ "$CURRENT_MIN" -ge "$RUN_WINDOW_START" ] && [ "$CURRENT_MIN" -lt "$RUN_WINDOW_END" ]; then
- logger "Within 1:00–1:30am window. Running Mover regardless of cache usage."
- SHOULD_RUN=1
- elif [ "$USAGE" -ge "$THRESHOLD" ]; then
- logger "Cache usage at ${USAGE}%. Running Mover and pausing containers."
- SHOULD_RUN=1
- else
- logger "Cache usage at ${USAGE}%. Outside time window. No action taken."
- SHOULD_RUN=0
- fi
- if [ "$SHOULD_RUN" -eq 1 ]; then
- # Pause containers
- docker pause binhex-sabnzbd
- docker pause binhex-radarr
- docker pause sonarr
- # Pause parity (optional)
- if command -v parity.check &> /dev/null; then
- logger "Pausing parity check using Parity Check Tuning plugin..."
- parity.check pause
- fi
- /usr/local/sbin/mover start
- # Wait for disk activity to stop
- sleep 60
- # Resume parity
- if command -v parity.check &> /dev/null; then
- logger "Resuming parity check..."
- parity.check resume
- fi
- echo "$(date): Resuming SABnzbd, Radarr and Sonarr"
- docker unpause binhex-sabnzbd
- docker unpause binhex-radarr
- docker unpause sonarr
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement