diff --git a/Dockerfile b/Dockerfile index 69312e9..3a4fda0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ ENV TORRENTLIST=https://raw.githubusercontent.com/ngosang/trackerslist/master/tr RUN apk add --update bash transmission-remote curl coreutils && \ rm -rf /var/cache/apk/* -COPY ./tracker-add-auto.sh /opt/tracker-add-auto.sh -RUN chmod +x /opt/tracker-add-auto.sh +COPY trackers.txt /opt/trackers.txt +COPY tracker-add-auto.sh /opt/tracker-add-auto.sh USER guest ENTRYPOINT [ "/opt/tracker-add-auto.sh" ] diff --git a/tracker-add-auto.sh b/tracker-add-auto.sh old mode 100644 new mode 100755 index d64dbcc..32f184d --- a/tracker-add-auto.sh +++ b/tracker-add-auto.sh @@ -4,37 +4,17 @@ add_trackers() { torrent_hash=$1 torrent_name=$2 id=$3 - for base_url in "$TORRENTLIST"; do - if [ ! -f /tmp/trackers.txt ]; then - curl -o "/tmp/trackers.txt" "${base_url}" - if [ -f /opt/trackers.txt ]; then - cat /opt/trackers.txt >>/tmp/trackers.txt - fi + echo "URL for ${base_url}" + echo "Adding trackers for $torrent_name ($torrent_hash)" + + for tracker in $(cat /tmp/trackers.txt); do + echo -n "${tracker}..." + if transmission-remote "$HOSTPORT" --authenv --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then + echo ' failed.' + else + echo ' done.' fi - - local=$(wc -c >/tmp/trackers.txt - fi - fi - - echo "URL for ${base_url}" - echo "Adding trackers for $torrent_name ($torrent_hash)" - - for tracker in $(cat /tmp/trackers.txt); do - echo -n "${tracker}..." - if transmission-remote "$HOSTPORT" --authenv --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then - echo ' failed.' - else - echo ' done.' - fi - done done sleep 3m @@ -42,10 +22,20 @@ add_trackers() { } while true; do + if [ ! -f /tmp/trackers.txt ] || [[ $(find "/tmp/trackers.txt" -mtime +1 -print) ]]; then + for base_url in "$TORRENTLIST"; do + curl -so "/tmp/trackers.txt" "${base_url}" + + if [ -f /opt/trackers.txt ]; then + cat /opt/trackers.txt >>/tmp/trackers.txt + fi + done + fi + # Get list of active torrents - ids="$(transmission-remote "$HOSTPORT" --authenv --list | grep -vE 'Seeding|Stopped|Finished|[[:space:]]100%[[:space:]]' | grep '^ ' | awk '{ print $1 }')" + ids="$(transmission-remote "$HOSTPORT" --authenv --list | grep -vE 'ETA|Seeding|Stopped|Finished|[[:space:]]100%[[:space:]]' | grep '^ ' | awk '{ print $1 }')" for id in $ids; do - echo Processing $id + echo "Processing: $id" if [ ! -f /tmp/TTAA.$id.lock ]; then hash="$(transmission-remote "$HOSTPORT" --authenv --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')" @@ -54,6 +44,7 @@ while true; do touch /tmp/TTAA.$id.lock fi done + wait sleep ${INTERVAL:-25} done diff --git a/trackers.txt b/trackers.txt new file mode 100644 index 0000000..403a18e --- /dev/null +++ b/trackers.txt @@ -0,0 +1 @@ +udp://incest.world:6969/announce \ No newline at end of file