Skip to content

Commit dfa16ee

Browse files
committed
Added docker support.
1 parent e6cb5f8 commit dfa16ee

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:latest
2+
ENV TRANSMISSION_HOST=localhost
3+
ENV TRANSMISSION_PORT=9091
4+
ENV TRANSMISSION_USER=admin
5+
ENV TRANSMISSION_PASSWORD=password
6+
ENV TRANSMISSION_FILTER=
7+
ENV TEMP=/tmp
8+
RUN pip3 install transmissionrpc & \
9+
mkdir /app
10+
COPY transmission-trackers.py /app
11+
COPY transmission-trackers.timer /app
12+
COPY transmission-trackers.service /app
13+
COPY requirements.txt /app
14+
COPY entrypoint.sh /
15+
RUN chmod +x /entrypoint.sh
16+
WORKDIR /app
17+
CMD /entrypoint.sh

entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#/bin/bash
2+
cd /app
3+
pip install -r /app/requirements.txt
4+
while (true); do
5+
python /app/transmission-trackers.py
6+
sleep 1m
7+
done

transmission-trackers.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
#!/usr/bin/env python3
22
from __future__ import print_function
3+
import os
34

45
# Host, port, username and password to connect to Transmission
56
# Set user and pw to None if auth is not required
67
client = {
7-
'host': 'localhost',
8-
'port': 9091,
9-
'user': 'admin',
10-
'password': 'passwd'
8+
'host': os.environ.get('TRANSMISSION_HOST'),
9+
'port': os.environ.get('TRANSMISSION_PORT'),
10+
'user': os.environ.get('TRANSMISSION_USER'),
11+
'password': os.environ.get('TRANSMISSION_PASSWORD')
1112
}
1213
config = {
1314

1415
# Work with torrents having only these statuses.
1516
# Can be any combination of: 'check pending', 'checking', 'downloading', 'seeding', 'stopped'
1617
# If empty - will affect all torrents
17-
'status_filter': (),
18+
'status_filter': (os.environ.get('TRANSMISSION_FILTER')),
1819

1920
# A list of URLs where to get the tracker lists from.
2021
# The lists are combined into one with duplicates removed.
@@ -48,7 +49,7 @@
4849
}
4950
cache_file = None # Universal scope
5051
from os import getcwd
51-
if getcwd() != '/docker/transmission/transmission-trackers':
52+
if getcwd() != '/app':
5253
from os import environ as env, path, mkdir
5354
try:
5455
cache_file = path.join(env.get('TEMP',env.get('TMP',None)) ,'.cache/trackers.txt')

0 commit comments

Comments
 (0)