Transmission script torrent done not working

I've been trying to get a script to run using transmissions "Script torrent done" feature, but nothing ever works. I've done a chmod +x on the script as well as a chown user:group /myscript that is the same user:group as defined in /etc/config/transmission, but nothing ever works. I've resorted to just referencing the script in /etc/crontabs/root file on a 1 minute timer but after years of doing it this way, its starting to have negative effects with other programs I'm using and creating unnecessary CPU load.

My question is if there is something i'm missing or some guide to implementing my script correctly into transmission because I've googled this countless times and the search results are always irrelevant to the platform, usage, or my inquiry about troubleshooting the "Script torrent done" script.

The script has run perfectly for years in crontabs but it's just time I look into migrating my script into transmission like i always meant for it to be.

Enable debugging with the following line in the beginning of the script:

set -x -v; exec &> /tmp/script.log
2 Likes
# tail /tmp/script.log
tail: can't open '/tmp/script.log': No such file or directory
tail: no files

Make sure the script starts with the proper shebang.
Also verify that you can run the script as the target user:

opkg update
opkg install shadow-su
su -l -c /path/to/script user

If the issue persists, set the proper shell for the user:

opkg update
opkg install shadow-usermod
usermod -s /bin/ash user
2 Likes

There is no change from transmissions end. I can however run the script manually now under the target user.

# su -l -c /etc/openvpn/finish1 immortal
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r21885-f86658e269
 -----------------------------------------------------
+ exec

Here is the log output from when I run it manually.

# cat /tmp/script.log
SERVER="192.168.6.1:9091"
+ SERVER=192.168.6.1:9091
TORRENTID=`transmission-remote $SERVER -l | grep 100% | awk '{print $1}'`
+ transmission-remote 192.168.6.1:9091 -l
+ awk '{print $1}'
+ grep '100%'
+ TORRENTID=1
transmission-remote $SERVER --torrent $TORRENTID --remove
+ transmission-remote 192.168.6.1:9091 --torrent 1 --remove
192.168.6.1:9091/transmission/rpc/ responded: "success"
#find /mnt/usb/dl/ -name "*.avi" -o -name "*.mp4" -o -name "*.mov" -o -name "*.mkv" > /tmp/something && rsync -ru `cat /tmp/something` /mnt/usb/stream/ && rm /tmp/something
rm /mnt/usb/stream/stats.json
+ rm /mnt/usb/stream/stats.json
rm: can't remove '/mnt/usb/stream/stats.json': No such file or directory

The part where it says responded: "success" on the 10th line is all I really care about so I now know that the script can run properly under the user that transmission is using.

1 Like

If the service is running under a restricted user, it cannot elevate own privileges to change the UID/GID to run your script.

You need to run the script under the same user as the service, or configure sudo to allow the service trigger the script with a different UID/GID.

1 Like

I am running the script under the same user as the service, no changes required.

This is the script:

ls -l
-rwxr-xr-x    1 immortal transmis       407 Mar 29 23:27 finish1

This is excerpts from the config file:

# cat /etc/config/transmission | grep user
        option user 'immortal'
# cat /etc/config/transmission | grep group
        option group 'transmission'

and the running process:

# ps | grep transmissio[n]
 7535 immortal  1180 SN   /sbin/seccomp-trace /usr/bin/transmission-daemon -f -g /mnt/usb/stream/
 7536 immortal  5064 SN   /usr/bin/transmission-daemon -f -g /mnt/usb/stream/
1 Like

I'm starting to remember why I said forget this feature and just put this script into crontabs 10 years ago. This feature simply don't work for me and infuriates me because everyone has a solution that doesn't work for me.

Thanks but no thanks guys. I'll be back in 10 years and we can try this again.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.