- Add 11 new stack compose files from syn01 and syn02 - syn01 stacks: postgres01, paperless-ngx, minio, beszel-hub, gitea, adguard - syn02 stacks: radarr, lidarr, sabnzbd, sonarr, arr-cleanup - Update resources.toml with all new stack definitions - Remove embedded file_contents from prowlarr stack - Use environment variables for sensitive data (passwords, API keys) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
112 lines
4.1 KiB
YAML
112 lines
4.1 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
arr-cleanup:
|
|
image: alpine:latest
|
|
container_name: arr-cleanup
|
|
restart: unless-stopped
|
|
environment:
|
|
- TZ=America/Los_Angeles
|
|
- RADARR_URL=${RADARR_URL:-http://192.168.1.52:7878}
|
|
- RADARR_API_KEY=${RADARR_API_KEY}
|
|
- SONARR_URL=${SONARR_URL:-http://192.168.1.52:8989}
|
|
- SONARR_API_KEY=${SONARR_API_KEY}
|
|
volumes:
|
|
- cleanup-scripts:/scripts
|
|
- cleanup-logs:/logs
|
|
entrypoint: /bin/sh
|
|
command:
|
|
- -c
|
|
- |
|
|
# Install dependencies
|
|
apk add --no-cache curl jq dcron
|
|
|
|
# Create Radarr cleanup script
|
|
cat > /scripts/cleanup-radarr.sh <<'EOF'
|
|
#!/bin/sh
|
|
echo "=== Radarr Cleanup (Unmonitored + No Files) ==="
|
|
echo "Fetching movie list..."
|
|
MOVIES=$$(curl -s "$${RADARR_URL}/api/v3/movie?apikey=$${RADARR_API_KEY}")
|
|
TO_DELETE=$$(echo "$$MOVIES" | jq -c '[.[] | select(.monitored == false and .hasFile == false)]')
|
|
COUNT=$$(echo "$$TO_DELETE" | jq 'length')
|
|
if [ "$$COUNT" -eq 0 ]; then
|
|
echo "No unmonitored movies found."
|
|
exit 0
|
|
fi
|
|
echo "Found $$COUNT unmonitored movies with no files:"
|
|
echo "$$TO_DELETE" | jq -r '.[] | " - \(.title) (\(.year))"'
|
|
echo "Deleting from Radarr..."
|
|
echo "$$TO_DELETE" | jq -c '.[]' | while read movie; do
|
|
ID=$$(echo "$$movie" | jq -r '.id')
|
|
TITLE=$$(echo "$$movie" | jq -r '.title')
|
|
curl -s -X DELETE "$${RADARR_URL}/api/v3/movie/$$ID?apikey=$${RADARR_API_KEY}&deleteFiles=false" > /dev/null
|
|
echo " ✓ Deleted: $$TITLE"
|
|
done
|
|
echo "=== Complete ==="
|
|
EOF
|
|
|
|
# Create Sonarr cleanup script
|
|
cat > /scripts/cleanup-sonarr.sh <<'EOF'
|
|
#!/bin/sh
|
|
echo "=== Sonarr Cleanup (Unmonitored + No Files) ==="
|
|
echo "Fetching series list..."
|
|
SERIES=$$(curl -s "$${SONARR_URL}/api/v3/series?apikey=$${SONARR_API_KEY}")
|
|
TO_DELETE=$$(echo "$$SERIES" | jq -c '[.[] | select(.monitored == false and .statistics.episodeFileCount == 0)]')
|
|
COUNT=$$(echo "$$TO_DELETE" | jq 'length')
|
|
if [ "$$COUNT" -eq 0 ]; then
|
|
echo "No unmonitored series found."
|
|
exit 0
|
|
fi
|
|
echo "Found $$COUNT unmonitored series with no files:"
|
|
echo "$$TO_DELETE" | jq -r '.[] | " - \(.title) (\(.year))"'
|
|
echo "Deleting from Sonarr..."
|
|
echo "$$TO_DELETE" | jq -c '.[]' | while read show; do
|
|
ID=$$(echo "$$show" | jq -r '.id')
|
|
TITLE=$$(echo "$$show" | jq -r '.title')
|
|
curl -s -X DELETE "$${SONARR_URL}/api/v3/series/$$ID?apikey=$${SONARR_API_KEY}&deleteFiles=false" > /dev/null
|
|
echo " ✓ Deleted: $$TITLE"
|
|
done
|
|
echo "=== Complete ==="
|
|
EOF
|
|
|
|
# Create master script
|
|
cat > /scripts/cleanup-all.sh <<'EOF'
|
|
#!/bin/sh
|
|
echo "========================================"
|
|
echo "ARR Services Auto-Cleanup"
|
|
echo "$(date)"
|
|
echo "========================================"
|
|
/scripts/cleanup-radarr.sh
|
|
echo ""
|
|
/scripts/cleanup-sonarr.sh
|
|
echo "========================================"
|
|
EOF
|
|
|
|
# Make executable
|
|
chmod +x /scripts/*.sh
|
|
|
|
# Setup cron (daily at 3 AM)
|
|
echo "0 3 * * * /scripts/cleanup-all.sh >> /logs/cleanup.log 2>&1" > /etc/crontabs/root
|
|
|
|
# Log startup
|
|
echo "========================================" | tee /logs/startup.log
|
|
echo "ARR Cleanup Container Ready" | tee -a /logs/startup.log
|
|
echo "$(date)" | tee -a /logs/startup.log
|
|
echo "Schedule: Daily at 3:00 AM" | tee -a /logs/startup.log
|
|
echo "Manual run: docker exec arr-cleanup /scripts/cleanup-all.sh" | tee -a /logs/startup.log
|
|
echo "View logs: docker exec arr-cleanup cat /logs/cleanup.log" | tee -a /logs/startup.log
|
|
echo "========================================" | tee -a /logs/startup.log
|
|
|
|
# Start cron
|
|
crond -f -l 2
|
|
networks:
|
|
- arr-network
|
|
|
|
networks:
|
|
arr-network:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
cleanup-scripts:
|
|
cleanup-logs:
|