Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ venv.bak/
.vscode

.pytest_cache/

config.yml
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.12-slim

# Install cron
RUN apt-get update && apt-get install -y cron && \
apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY . /app

RUN pip install --no-cache-dir .

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]
9 changes: 9 additions & 0 deletions config.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
my_task:
client: transmission
host: http://localhost
username: admin
password: verysecurepassword
strategies:
my_strategy:
remove: seeding_time > 2592000 or ratio > 1.99
delete_data: true
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.9"

services:
autoremove-torrents:
container_name: autoremove-torrents
image: timothe/autoremove-torrents:latest
network_mode: host
environment:
- CRON=0 3 * * * # Run once a day at 3 AM
volumes:
- /your/local/path/config.yml:/app/config.yml
restart: unless-stopped
24 changes: 24 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e

if [ -z "$CRON" ]; then
echo "Error: CRON environment variable not set"
exit 1
fi

echo "Setting up cron job with schedule: '$CRON'"

# Write the cron schedule to a crontab file
echo "$CRON /usr/local/bin/autoremove-torrents --conf /app/config.yml >> /var/log/cron.log 2>&1" > /etc/cron.d/autoremove-cron

# Apply correct permissions
chmod 0644 /etc/cron.d/autoremove-cron

# Register the new cron job
crontab /etc/cron.d/autoremove-cron

# Create the log file
touch /var/log/cron.log

# Start cron in foreground
cron && tail -f /var/log/cron.log