diff --git a/tracker-add-auto.sh b/tracker-add-auto.sh index 2acd3d2..2fe912b 100644 --- a/tracker-add-auto.sh +++ b/tracker-add-auto.sh @@ -14,15 +14,15 @@ while true; do trackerslist=/tmp/trackers.txt for base_url in $trackers; do if [ ! -f $trackerslist ]; then - curl -o "$trackerslist" "${base_url}" + curl -s --output /dev/null --show-error -o "$trackerslist" "${base_url}" fi Local=$(wc -c <$trackerslist) Remote=$(curl -sI "${base_url}" | awk '/Content-Length/ {sub("\r",""); print $2}') if [ "$Local" != "$Remote" ]; then - curl -o "$trackerslist" "${base_url}" + curl -s --output /dev/null --show-error -o "$trackerslist" "${base_url}" fi echo "URL for ${base_url}" - echo "Adding trackers for $torrent_name..." + echo "Adding trackers for \"$torrent_name\" ($torrent_hash)..." for tracker in $(cat $trackerslist); do echo -n "${tracker}..." if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then @@ -35,8 +35,9 @@ while true; do sleep 3m rm -f "/tmp/TTAA.$id.lock" } + # Get list of active torrents - ids="$(transmission-remote "$host" --auth="$auth" --list | grep -vE 'Seeding|Stopped|Finished|[[:space:]]100%[[:space:]]' | grep '^ ' | awk '{ print $1 }')" + ids="$(transmission-remote "$host" --auth="$auth" --list | tail -n +2 | grep -vE 'Seeding|Stopped|Finished|[[:space:]]100%[[:space:]]' | grep '^ ' | awk '{ print $1 }')" for id in $ids; do add_date="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Date added: ' | cut -c 21-)" add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")" @@ -54,7 +55,11 @@ while true; do torrent_name="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Name: ' | cut -c 9-)" add_trackers "$hash" "$id" & touch "/tmp/TTAA.$id.lock" + else + echo "Skipping. Torrent #$id ($hash) was just added." fi + else + echo "Trackers already added for torrent #$id. A file lock was found." fi done done diff --git a/transmission-tracker-add.service b/transmission-tracker-add.service index 42d74f0..1342ef9 100644 --- a/transmission-tracker-add.service +++ b/transmission-tracker-add.service @@ -6,11 +6,11 @@ Requires=network.target ### use non root user example below: #User=debian-transmission Type=simple -ExecStart=/opt/bin/add-trackers-auto.sh +ExecStart=/opt/tracker-add/bin/tracker-add-auto.sh ExecStop=/bin/kill -s TERM $MAINPID -ExecStopPost=/bin/rm -f /tmp/TTAA.*.lock +ExecStopPost=/bin/sh -c '/bin/rm -vf /tmp/TTAA.*.lock' KillMode=control-group -StandardOutput=null +StandardOutput=journal CPUSchedulingPolicy=idle Nice=19