Skip to content

Instantly share code, notes, and snippets.

@kenstir
Last active February 16, 2025 00:41
Show Gist options
  • Save kenstir/e62bb85cc719105d99d691b817dbbb5e to your computer and use it in GitHub Desktop.
Save kenstir/e62bb85cc719105d99d691b817dbbb5e to your computer and use it in GitHub Desktop.
linuxserver/deluge:2.1.1 reannounce script
#!/bin/bash
# This script came from [HBD](https://docs.hostingby.design/application-hosting/applications/deluge#reannounce-script)
# and was edited to work in a linuxserver/deluge:2.1.1 container
# Change the below output location to any folder owned by your user for which you have write permissions
OUTPUT="/opt/log/"
torrentid=$1
torrentname=$2
torrentpath=$3
# Update the ip & port below according to your configuration
ip=127.0.0.1
port=58846
deluge_console="deluge-console -c /config"
x=1
while [ $x -le 60 ]; do
sleep 7
echo "Running $x times" >> "${OUTPUT}/script.log"
echo "TorrentID: $torrentid" >> "${OUTPUT}/script.log"
# echo >&2 "executing: $deluge_console info -d $torrentid"
info=$($deluge_console info -d $torrentid 2>> "${OUTPUT}/deluge.output")
line=$(echo "$info" | grep "Tracker status")
# echo $line >> "${OUTPUT}/script.log"
case "$line" in
*unregistered* | *Sent* | *End*of*file* | *Bad*Gateway* | *Error*)
# echo >&2 "executing: $deluge_console reannounce $torrentid"
$deluge_console reannounce $torrentid >> "${OUTPUT}/deluge.output" 2>&1
;;
*)
seeds=$(echo "$info" | grep "Seeds")
total_seeds=$(echo $seeds | awk '{print $3}' | sed -r 's/\(|\)//g')
connected_seeds=$(echo $seeds | awk '{print $2}')
echo "Seeds: $connected_seeds ($total_seeds)" >> "${OUTPUT}/script.log" 2>&1
if (($connected_seeds > 0)) || (($total_seeds > 0)); then
y=1
while [ $y -le 2 ]; do
sleep 30
echo "Extra updates running $y times" >> "${OUTPUT}/extra.log" 2>&1
# echo >&2 "executing: $deluge_console update_tracker $torrentid"
$deluge_console update_tracker $torrentid >> "${OUTPUT}/deluge.output" 2>&1
y=$(($y + 1))
done
echo "Found working torrent: $torrentname $torrentpath $torrentid" >> "${OUTPUT}/script.log" 2>&1
exit 1
else
# echo >&2 "executing: $deluge_console reannounce $torrentid"
$deluge_console reannounce $torrentid >> "${OUTPUT}/deluge.output" 2>&1
fi
;;
esac
x=$(($x + 1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment