Skip to content

Commit 0691f9e

Browse files
Update tracker-add-auto.sh
cosmetic fixes
1 parent 99201fc commit 0691f9e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tracker-add-auto.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ sleep 25
88
add_trackers () {
99
torrent_hash=$1
1010
id=$2
11+
trackerslist=/tmp/trackers.txt
1112
for base_url in https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt ; do
12-
if [ ! -f /tmp/trackers.txt ]; then
13-
curl -o "/tmp/trackers.txt" "${base_url}"
13+
if [ ! -f $trackerslist ]; then
14+
curl -o "$trackerslist" "${base_url}"
1415
fi
15-
Local=$(wc -c < /tmp/trackers.txt)
16+
Local=$(wc -c < $trackerslist)
1617
Remote=$(curl -sI "${base_url}" | awk '/Content-Length/ {sub("\r",""); print $2}')
17-
if [ $Local != $Remote ]; then
18-
curl -o "/tmp/trackers.txt" "${base_url}"
18+
if [ "$Local" != "$Remote" ]; then
19+
curl -o "$trackerslist" "${base_url}"
1920
fi
2021
echo "URL for ${base_url}"
2122
echo "Adding trackers for $torrent_name..."
22-
for tracker in $(cat /tmp/trackers.txt) ; do
23+
for tracker in $(cat $trackerslist) ; do
2324
echo -n "${tracker}..."
2425
if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
2526
echo ' failed.'
@@ -29,7 +30,7 @@ fi
2930
done
3031
done
3132
sleep 3m
32-
rm -f /tmp/TTAA.$id.lock
33+
rm -f "/tmp/TTAA.$id.lock"
3334
}
3435
# Get list of active torrents
3536
ids="$(transmission-remote "$host" --auth="$auth" --list | grep -vE 'Seeding|Stopped|Finished|[[:space:]]100%[[:space:]]' | grep '^ ' | awk '{ print $1 }')"
@@ -39,12 +40,12 @@ for id in $ids ; do
3940
dater="$(date "+%Y-%m-%d %H:%M")"
4041
dateo="$(date -d "1 minutes ago" "+%Y-%m-%d %H:%M")"
4142

42-
if [ ! -f /tmp/TTAA.$id.lock ]; then
43-
if [[ ( "$add_date_t" == "$dater" || "$add_date_t" == "$dateo" ) ]]; then
43+
if [ ! -f "/tmp/TTAA.$id.lock" ]; then
44+
if [[ "( "$add_date_t" == "$dater" || "$add_date_t" == "$dateo" )" ]]; then
4445
hash="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
4546
torrent_name="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)"
4647
add_trackers "$hash" "$id" &
47-
touch /tmp/TTAA.$id.lock
48+
touch "/tmp/TTAA.$id.lock"
4849
fi
4950
fi
5051
done

0 commit comments

Comments
 (0)