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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ Nice=19

#### Choose your destiny:

[Docker way](https://github.com/AndrewMarchukov/tracker-add#-docker-way)
[Docker way](#-docker-way)

[Systemd way](https://github.com/AndrewMarchukov/tracker-add#-systemd-way)
[Systemd way](#-systemd-way)

[Simple way (for routers)](https://github.com/AndrewMarchukov/tracker-add#-simple-way-for-routers)
[FreeBSD service way](#-freebsd-service-way)

[Simple way (for routers)](#-simple-way-for-routers)

## Installation and usage

Expand Down Expand Up @@ -95,6 +97,29 @@ systemctl status transmission-tracker-add.service

```


#### * FreeBSD service way

Edit settings.json for transmission set rpc-enabled, rpc-username and rpc-password

Download scripts and make it executable:
```bash
install -d /opt/bin
fetch -o /opt/bin/add-trackers-auto.sh https://raw.githubusercontent.com/AndrewMarchukov/tracker-add/master/tracker-add-auto.sh
fetch -o /usr/local/etc/rc.d/transmission_tracker_add https://raw.githubusercontent.com/AndrewMarchukov/tracker-add/master/transmission_tracker_add
chmod +x /opt/bin/add-trackers-auto.sh /usr/local/etc/rc.d/transmission_tracker_add
```

Set user and password in `add-trackers-auto.sh`:
```bash
nano /opt/bin/add-trackers-auto.sh
```

Start service:
```bash
service transmission_tracker_add start
```

#### * Simple way (for routers)

Requirements: curl, transmission-remote
Expand Down
Empty file modified tracker-add-auto-router.sh
100644 → 100755
Empty file.
16 changes: 9 additions & 7 deletions tracker-add-auto.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash
#!/bin/sh
# Get transmission credentials and ip or dns address
auth=user:password
host=localhost
# set trackers list space separated
trackers=https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt
pt_trackers=()

trans="/usr/local/bin/transmission-remote $host --auth=$auth"

while true; do
sleep 25
add_trackers() {
Expand All @@ -25,7 +27,7 @@ while true; do
echo "Adding trackers for $torrent_name..."
for tracker in $(cat $trackerslist); do
echo -n "${tracker}..."
if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
if ${trans} --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then
echo ' done.'
else
echo ' already added.'
Expand All @@ -36,22 +38,22 @@ while true; do
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="$(${trans} --list | 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="$(${trans} --torrent "$id" --info | grep '^ Date added: ' | cut -c 21-)"
add_date_t="$(date -d "$add_date" "+%Y-%m-%d %H:%M")"
dater="$(date "+%Y-%m-%d %H:%M")"
dateo="$(date -d "1 minutes ago" "+%Y-%m-%d %H:%M")"
tracker0="$(transmission-remote "$host" --auth="$auth" -t "$id" -it | sed -n '2,2p' | awk '{print $3}' | awk -F : '{print $2}' | sed -e 's/\/\///')"
tracker0="$(${trans} -t "$id" -it | sed -n '2,2p' | awk '{print $3}' | awk -F : '{print $2}' | sed -e 's/\/\///')"
if [[ " ${pt_trackers[@]} " =~ " $tracker0 " ]]; then
echo "skip id=" "$id" "$tracker0"
continue
fi

if [ ! -f "/tmp/TTAA.$id.lock" ]; then
if [[ "( "$add_date_t" == "$dater" || "$add_date_t" == "$dateo" )" ]]; then
hash="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
torrent_name="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Name: ' | cut -c 9-)"
hash="$(${trans} --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')"
torrent_name="$(${trans} --torrent "$id" --info | grep '^ Name: ' | cut -c 9-)"
add_trackers "$hash" "$id" &
touch "/tmp/TTAA.$id.lock"
fi
Expand Down
22 changes: 22 additions & 0 deletions transmission_tracker_add
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#
# PROVIDE: transmission_tracker_add
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

name=transmission_tracker_add
rcvar=transmission_tracker_add_enable

load_rc_config $name

: ${transmission_tracker_add_enable:=YES}

pidfile=/var/run/transmission/tracker-add.pid
command="/usr/sbin/daemon"
task="/opt/bin/add-trackers-auto.sh"
procname="/bin/sh"
command_args="-p ${pidfile} ${task}"

run_rc_command "$1"