From 6fca26f2084914484a1c3cf029e040e30a5b59fb Mon Sep 17 00:00:00 2001 From: pataquets Date: Mon, 23 Mar 2020 03:15:25 +0100 Subject: [PATCH 01/12] Allow specifying host, user, pass and tracker URL via environment vars. Make curl follow redirects. --- manual-tracker-add.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manual-tracker-add.sh b/manual-tracker-add.sh index 8f23f6c..6bc1964 100755 --- a/manual-tracker-add.sh +++ b/manual-tracker-add.sh @@ -1,17 +1,18 @@ #!/bin/bash # Get transmission credentials -auth=user:password -host=localhost +auth=${TRANSMISSION_USER:-user}:${TRANSMISSION_PASS:-password} +host=${TRANSMISSION_HOST:-localhost} +list_url=${TRACKER_URL:-https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt} add_trackers () { torrent_hash=$1 - for base_url in https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt ; do + for base_url in "${list_url}" ; do echo -e "\e[1m\e[5m" echo "URL for ${base_url}" echo -e "Adding trackers for \e[91m$torrent_name..." echo -en "\e[0m" echo -e "\e[2m\e[92m" -for tracker in $(curl -# "${base_url}") ; do +for tracker in $(curl --location -# "${base_url}") ; do echo -en "\e[0m" echo -ne "\e[93m*\e[0m ${tracker}..." if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then From c5d719cab8cad79806ec231b60714f0c9bb2864b Mon Sep 17 00:00:00 2001 From: pataquets Date: Tue, 24 Mar 2020 03:25:52 +0100 Subject: [PATCH 02/12] Allow passing a quoted enclosed, space separated list of torrent ids as an argument. --- manual-tracker-add.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual-tracker-add.sh b/manual-tracker-add.sh index 6bc1964..e5d7828 100755 --- a/manual-tracker-add.sh +++ b/manual-tracker-add.sh @@ -27,7 +27,7 @@ done } # Get list of active torrents -ids="$(transmission-remote "$host" --auth="$auth" --list | grep -vE 'Seeding|Stopped|Finished' | grep '^ ' | awk '{ print $1 }')" +ids=${1:-"$(transmission-remote "$host" --auth="$auth" --list | grep -vE 'Seeding|Stopped|Finished' | grep '^ ' | awk '{ print $1 }')"} for id in $ids ; do hash="$(transmission-remote "$host" --auth="$auth" --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')" From 9c3bd25cd440f235377bd7a9d2866d5cd191cceb Mon Sep 17 00:00:00 2001 From: Dan Lenski Date: Wed, 15 Apr 2020 09:23:01 -0700 Subject: [PATCH 03/12] don't send --auth option if TRANSMISSION_USER/PASS are unset Handle the common case of localhost-only transmission running without authentication --- manual-tracker-add.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/manual-tracker-add.sh b/manual-tracker-add.sh index e5d7828..1afe076 100755 --- a/manual-tracker-add.sh +++ b/manual-tracker-add.sh @@ -1,6 +1,10 @@ #!/bin/bash -# Get transmission credentials -auth=${TRANSMISSION_USER:-user}:${TRANSMISSION_PASS:-password} +# Get transmission credentials, if set +if [[ -n "$TRANSMISSION_USER" && -n "$TRANSMISSION_PASS" ]]; then + auth="${TRANSMISSION_USER:-user}:${TRANSMISSION_PASS:-password}" +else + auth= +fi host=${TRANSMISSION_HOST:-localhost} list_url=${TRACKER_URL:-https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt} @@ -15,7 +19,7 @@ add_trackers () { for tracker in $(curl --location -# "${base_url}") ; do echo -en "\e[0m" echo -ne "\e[93m*\e[0m ${tracker}..." -if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then +if transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then echo -e '\e[91m failed.' echo -en "\e[0m" else @@ -27,10 +31,10 @@ done } # Get list of active torrents -ids=${1:-"$(transmission-remote "$host" --auth="$auth" --list | grep -vE 'Seeding|Stopped|Finished' | grep '^ ' | awk '{ print $1 }')"} +ids=${1:-"$(transmission-remote "$host" ${auth:+--auth="$auth"} --list | grep -vE 'Seeding|Stopped|Finished' | grep '^ ' | awk '{ print $1 }')"} for id in $ids ; do - 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="$(transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "$id" --info | grep '^ Hash: ' | awk '{ print $2 }')" + torrent_name="$(transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "$id" --info | grep '^ Name: ' |cut -c 9-)" add_trackers "$hash" done From 04d5da1435014a14b95a5b46d7c4c342ec9cc53d Mon Sep 17 00:00:00 2001 From: Javinator9889 Date: Mon, 25 May 2020 10:53:29 +0200 Subject: [PATCH 04/12] Update manual-tracker grep behaviour According to manual page and StackOverflow, when there is a match grep returns 'SUCCESS', so the logic of the 'if' code must be inverted. In addition, for better output readability, instead of "failure" the output may be "already added" as `transmission-remote` says "Invalid argument" when a torrent has the specific tracker included --- manual-tracker-add.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manual-tracker-add.sh b/manual-tracker-add.sh index 1afe076..922a663 100755 --- a/manual-tracker-add.sh +++ b/manual-tracker-add.sh @@ -20,10 +20,10 @@ for tracker in $(curl --location -# "${base_url}") ; do echo -en "\e[0m" echo -ne "\e[93m*\e[0m ${tracker}..." if transmission-remote "$host" ${auth:+--auth="$auth"} --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then - echo -e '\e[91m failed.' + echo -e '\e[92m done.' echo -en "\e[0m" else - echo -e '\e[92m done.' + echo -e '\e[93m already added.' echo -en "\e[0m" fi done From 6ef556358c412bab69e3551a7a441c7e7478e34d Mon Sep 17 00:00:00 2001 From: Javinator9889 Date: Mon, 25 May 2020 10:56:42 +0200 Subject: [PATCH 05/12] Update tracker-add-auto.sh The same behavior described in 04d5da1435014a14b95a5b46d7c4c342ec9cc53d applies here --- tracker-add-auto.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracker-add-auto.sh b/tracker-add-auto.sh index 44c417e..683a354 100644 --- a/tracker-add-auto.sh +++ b/tracker-add-auto.sh @@ -23,9 +23,9 @@ fi for tracker in $(cat $trackerslist) ; do echo -n "${tracker}..." if transmission-remote "$host" --auth="$auth" --torrent "${torrent_hash}" -td "${tracker}" | grep -q 'success'; then - echo ' failed.' -else echo ' done.' +else + echo ' already added.' fi done done From a764d6eaa343945ff899181d9f812d13863028b7 Mon Sep 17 00:00:00 2001 From: Andrew Marchukov Date: Tue, 11 May 2021 22:59:37 +0300 Subject: [PATCH 06/12] make prettier --- tracker-add-auto.sh | 99 +++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/tracker-add-auto.sh b/tracker-add-auto.sh index 93ebe4b..2acd3d2 100644 --- a/tracker-add-auto.sh +++ b/tracker-add-auto.sh @@ -2,58 +2,59 @@ # 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=() -while true ; do -sleep 25 -add_trackers () { - torrent_hash=$1 - id=$2 - trackerslist=/tmp/trackers.txt -for base_url in $trackers ; do -if [ ! -f $trackerslist ]; then -curl -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}" -fi - echo "URL for ${base_url}" - 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 - echo ' done.' -else - echo ' already added.' -fi -done -done - sleep 3m - rm -f "/tmp/TTAA.$id.lock" -} -# Get list of active torrents +while true; do + sleep 25 + add_trackers() { + torrent_hash=$1 + id=$2 + trackerslist=/tmp/trackers.txt + for base_url in $trackers; do + if [ ! -f $trackerslist ]; then + curl -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}" + fi + echo "URL for ${base_url}" + 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 + echo ' done.' + else + echo ' already added.' + fi + done + done + 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 }')" -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")" - 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/\/\///')" - if [[ " ${pt_trackers[@]} " =~ " $tracker0 " ]]; then - echo "skip id=" $id $tracker0 - continue - fi + 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")" + 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/\/\///')" + 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-)" - add_trackers "$hash" "$id" & - touch "/tmp/TTAA.$id.lock" -fi -fi -done + 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-)" + add_trackers "$hash" "$id" & + touch "/tmp/TTAA.$id.lock" + fi + fi + done done From c72f18027481d46f933e134991a4f12cefd8b98d Mon Sep 17 00:00:00 2001 From: Andrew Marchukov Date: Fri, 20 May 2022 11:45:55 +0400 Subject: [PATCH 07/12] Create docker-image.yml --- .github/workflows/docker-image.yml | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..f6f7514 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,37 @@ +name: Docker Image CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: "0 23 1 * *" +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: andrewmhub/transmission-tracker-add:latest From 944bbf973680ee2f458ae542dedef72d62e289e4 Mon Sep 17 00:00:00 2001 From: Andrew Marchukov Date: Fri, 20 May 2022 11:58:12 +0400 Subject: [PATCH 08/12] Update docker-image.yml --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index f6f7514..6be1c6e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,9 +2,9 @@ name: Docker Image CI on: push: - branches: [ master ] + branches: [ docker ] pull_request: - branches: [ master ] + branches: [ docker ] schedule: - cron: "0 23 1 * *" jobs: From 0f0acab6757d3227b8216017635fc3fe3ebd3a80 Mon Sep 17 00:00:00 2001 From: AndrewMarchukov Date: Fri, 20 May 2022 12:08:31 +0400 Subject: [PATCH 09/12] deleted workflow --- .github/workflows/docker-image.yml | 37 ------------------------------ 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index 6be1c6e..0000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Docker Image CI - -on: - push: - branches: [ docker ] - pull_request: - branches: [ docker ] - schedule: - - cron: "0 23 1 * *" -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@master - with: - platforms: all - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@master - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm/v7,linux/arm64 - push: true - tags: andrewmhub/transmission-tracker-add:latest From 9430f51b05c2338f769b5c15968006b3f91b6e0b Mon Sep 17 00:00:00 2001 From: Andrew Marchukov Date: Wed, 25 May 2022 11:59:19 +0400 Subject: [PATCH 10/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e144ad2..1d6add9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Get more trackers, get more seeders, get more peers transmission [![](https://images.microbadger.com/badges/version/andrewmhub/transmission-tracker-add.svg)](https://microbadger.com/images/andrewmhub/transmission-tracker-add) ![Docker Pulls](https://img.shields.io/docker/pulls/andrewmhub/transmission-tracker-add.svg) ![GitHub top language](https://img.shields.io/github/languages/top/AndrewMarchukov/tracker-add.svg) +# Get more trackers, get more seeders, get more peers transmission [![Docker Image CI](https://github.com/AndrewMarchukov/tracker-add/actions/workflows/docker-image.yml/badge.svg?branch=docker)](https://github.com/AndrewMarchukov/tracker-add/actions/workflows/docker-image.yml) [![](https://images.microbadger.com/badges/version/andrewmhub/transmission-tracker-add.svg)](https://microbadger.com/images/andrewmhub/transmission-tracker-add) ![Docker Pulls](https://img.shields.io/docker/pulls/andrewmhub/transmission-tracker-add.svg) ![GitHub top language](https://img.shields.io/github/languages/top/AndrewMarchukov/tracker-add.svg) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/andrewmhub/transmission-tracker-add/latest) See no peers,seeds for some torrent(s)? Add more tracker(s) for Transmission This script automatically checks new torrents and adds trackers From 3ec8afd4cde259d905dfec241ba89ae2f012ea21 Mon Sep 17 00:00:00 2001 From: Andrew Marchukov Date: Wed, 25 May 2022 12:01:45 +0400 Subject: [PATCH 11/12] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d6add9..31969dd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Get more trackers, get more seeders, get more peers transmission [![Docker Image CI](https://github.com/AndrewMarchukov/tracker-add/actions/workflows/docker-image.yml/badge.svg?branch=docker)](https://github.com/AndrewMarchukov/tracker-add/actions/workflows/docker-image.yml) [![](https://images.microbadger.com/badges/version/andrewmhub/transmission-tracker-add.svg)](https://microbadger.com/images/andrewmhub/transmission-tracker-add) ![Docker Pulls](https://img.shields.io/docker/pulls/andrewmhub/transmission-tracker-add.svg) ![GitHub top language](https://img.shields.io/github/languages/top/AndrewMarchukov/tracker-add.svg) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/andrewmhub/transmission-tracker-add/latest) +# Get more trackers, get more seeders, get more peers transmission +[![Docker Image CI](https://github.com/AndrewMarchukov/tracker-add/actions/workflows/docker-image.yml/badge.svg?branch=docker)](https://github.com/AndrewMarchukov/tracker-add/actions/workflows/docker-image.yml) [![](https://images.microbadger.com/badges/version/andrewmhub/transmission-tracker-add.svg)](https://microbadger.com/images/andrewmhub/transmission-tracker-add) ![Docker Pulls](https://img.shields.io/docker/pulls/andrewmhub/transmission-tracker-add.svg) ![GitHub top language](https://img.shields.io/github/languages/top/AndrewMarchukov/tracker-add.svg) ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/andrewmhub/transmission-tracker-add/latest) + See no peers,seeds for some torrent(s)? Add more tracker(s) for Transmission This script automatically checks new torrents and adds trackers From 0a338693def6f4f3b215c7fb165f3d530c751a85 Mon Sep 17 00:00:00 2001 From: Andrew Marchukov Date: Thu, 6 Oct 2022 03:09:45 +0400 Subject: [PATCH 12/12] Create dependabot.yml --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..91ccc92 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 10 +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 10