so I found a script that will send me a telegram alarm everytime transmission finishes torrent download.
When the script runs successfully once it will continue to work throughout the day however when i reboot my cloud it doesn’t work anymore.
it seems that this script will only work if I run it after an initial torrent download. so basically it doesn’t work if i run it before an initial torrent download. (but it’s strange because this script is programmed to run when torrent download finishes)
If I run it before initial torrent download = not working
If I run it after a initial torrent down load - it works and also works throughout the day
Can anyone give me some advice??
Thanks.
the script is like below:
#!/bin/sh
setting
SERVER=“9091 --auth id:pw”
TOKEN=‘000000000:AAaaAaAA’
CHAT_ID=“000000000”
URL='https://api.telegram.org/bot’$TOKEN
MSG_URL=$URL’/sendMessage?chat_id=’
sleep 1s
do
TORRENTLIST=transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut -s -d " " -f 1
for TORRENTID in $TORRENTLIST
do
DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`
STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`
if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then
transmission-remote $SERVER --torrent $TORRENTID --remove
curl --data-urlencode "text=$TR_TORRENT_NAME download completed." "$MSG_URL"$CHAT_ID"&"
fi
done