gallyjh
Dabbler
- Joined
- Jun 6, 2018
- Messages
- 28
Hi, I've scoured google and the forums and tried several solutions but none have worked so far. Hoping it's something simple I'm missing.
Here is what the directory of settings.json and script cleanup-torrents.sh looks like:
As the title says, when I run my script by hand:
I get my expected results:
I've updated the following lines in the settings.json file:
Now, of course, I stopped the transmission service first, then updated the settings, then restarted the service. As you can see, I've thrown some debug statements in to see what might be happening. What I've discovered is the script is being ran, because a "test" file is being created by the touch command. I however get two blank carriage returns in the "test" file where I echo those commands in.
Whereas by hand I get the following in the "test" file:
Which made me think it's a permission problem with the command transmission-remote, so I checked the permissions on that:
I tried changing the owner to transmission:transmission for tranmission-remote, but that didn't help. So I put that back to root:wheel.
Here is the output of ps -aux, in case that may hint towards something:
Any suggestions on this?
Here is what the directory of settings.json and script cleanup-torrents.sh looks like:
root@transmission_1:/var/db/transmission # ls -al
total 94
drwxr-x--- 5 transmission transmission 11 Aug 6 20:43 .
drwxr-xr-x 14 root wheel 18 Jul 22 13:17 ..
drwxrwxrwx 2 transmission transmission 2 Jul 20 13:53 blocklists
-rwxr-xr-x 1 transmission transmission 1248 Aug 6 20:41 cleanup-torrents.sh
-rw------- 1 transmission transmission 688 Aug 6 18:07 dht.dat
drwxrwxrwx 2 transmission transmission 2 Aug 6 20:52 resume
-rw------- 1 transmission transmission 2356 Aug 6 18:07 settings.json
-rw------- 1 transmission transmission 2356 Aug 6 17:37 settings.json.save
-rw------- 1 transmission transmission 150 Aug 6 20:07 stats.json
-rw-r--r-- 1 transmission transmission 163 Aug 6 20:52 test
drwxrwxrwx 2 transmission transmission 2 Aug 6 20:52 torrents
As the title says, when I run my script by hand:
#!/bin/sh
cd /var/db/transmission/
DIR=`pwd`
echo "$DIR"
touch test
# port, username, password
SERVER="--auth ZZZZZ:XXXXX"
WORKING=`transmission-remote $SERVER --list`
# use transmission-remote to get torrent list from transmission-remote list
TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d' -e '$d' | awk '{print $1}' | sed -e 's/[^0-9]*//g'`
echo $TORRENTLIST >> test
echo $WORKING >> test
# for each torrent in the list
for TORRENTID in $TORRENTLIST
do
INFO=$(transmission-remote $SERVER --torrent $TORRENTID --info)
echo -e "Processing #$TORRENTID - $(echo $INFO | sed -e 's/.*Name: \(.*\) Hash.*/\1/')"
# check if torrent download is completed
DL_COMPLETED=`echo $INFO | grep "Done: 100%"`
# check torrents current state is
STATE_STOPPED=`echo $INFO | grep "State: Seeding\|State: Stopped\|State: Finished\|State: Idle"`
# if the torrent is "Stopped", "Finished", or "Idle after downloading 100%"
if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then
echo "Torrent #$TORRENTID is completed. Removing torrent from list."
transmission-remote $SERVER --torrent $TORRENTID --remove
else
echo "Torrent #$TORRENTID is not completed. Ignoring."
fi
done
I get my expected results:
root@transmission_1:/var/db/transmission # ./cleanup-torrents.sh
/var/db/transmission
Processing #7 - My torrent test
Torrent #7 is completed. Removing torrent from list.
localhost:9091/transmission/rpc/ responded: "success"
I've updated the following lines in the settings.json file:
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/var/db/transmission/cleanup-torrents.sh",
Now, of course, I stopped the transmission service first, then updated the settings, then restarted the service. As you can see, I've thrown some debug statements in to see what might be happening. What I've discovered is the script is being ran, because a "test" file is being created by the touch command. I however get two blank carriage returns in the "test" file where I echo those commands in.
Whereas by hand I get the following in the "test" file:
root@transmission_1:/var/db/transmission # cat test
7
ID Done Have ETA Up Down Ratio Status Name 7 100% 1.74 MB Done 0.0 0.0 0.0 Idle NCH Debut Video Capture Software v2 02 incl Keygen-LAXiTY Sum: 1.74 MB 0.0 0.0
Which made me think it's a permission problem with the command transmission-remote, so I checked the permissions on that:
root@transmission_1:/var/db/transmission # ls -al /usr/pbi/transmission-amd64/bin/
total 967
drwxr-xr-x 2 root wheel 30 Mar 10 20:27 .
drwxr-xr-x 17 root wheel 27 Jul 20 13:09 ..
lrwxr-xr-x 1 root wheel 8 Jun 27 2015 2to3-2 -> 2to3-2.7
-rwxr-xr-x 1 root wheel 118 Jun 27 2015 2to3-2.7
-rwxr-xr-x 1 root wheel 167072 Feb 26 2016 curl
-r-xr-xr-x 1 root wheel 6479 Feb 26 2016 curl-config
-r-xr-xr-x 1 root wheel 15656 Dec 9 2014 dht-example
-rwxr-xr-x 1 root wheel 150 Jun 27 2015 django-admin.py
-rwxr-xr-x 1 root wheel 346 Jun 27 2015 easy_install
-rwxr-xr-x 1 root wheel 354 Jun 27 2015 easy_install-2.7
-r-xr-xr-x 1 root wheel 55456 Dec 9 2014 event_rpcgen.py
-rwxr-xr-x 1 root wheel 153 Dec 9 2014 external-ip
-r-xr-xr-x 1 root wheel 25512 Dec 9 2014 iconv
lrwxr-xr-x 1 root wheel 7 Jun 27 2015 idle2 -> idle2.7
-rwxr-xr-x 1 root wheel 116 Jun 27 2015 idle2.7
-rwxr-xr-x 1 root wheel 8888 Dec 9 2014 indexinfo
-rwxr-xr-x 1 root wheel 9624 Dec 9 2014 natpmpc
lrwxr-xr-x 1 root wheel 8 Jun 27 2015 pydoc2 -> pydoc2.7
-rwxr-xr-x 1 root wheel 101 Jun 27 2015 pydoc2.7
lrwxr-xr-x 1 root wheel 9 Jun 27 2015 python2 -> python2.7
lrwxr-xr-x 1 root wheel 16 Jun 27 2015 python2-config -> python2.7-config
-r-xr-xr-x 1 root wheel 5176 Jun 27 2015 python2.7
-r-xr-xr-x 1 root wheel 1704 Jun 27 2015 python2.7-config
-rwxr-xr-x 1 root wheel 70136 Jan 31 2015 sqlite3
-r-xr-xr-x 1 root wheel 427376 Mar 10 20:27 transmission-daemon
-r-xr-xr-x 1 root wheel 448472 Mar 10 20:27 transmission-remote
-rwxr-xr-x 1 root wheel 23552 Dec 9 2014 upnpc
-r-xr-xr-x 1 root wheel 12656 Feb 1 2015 utp_recv
-r-xr-xr-x 1 root wheel 13656 Feb 1 2015 utp_send
-r-xr-xr-x 1 root wheel 15720 Feb 1 2015 utp_test
I tried changing the owner to transmission:transmission for tranmission-remote, but that didn't help. So I put that back to root:wheel.
Here is the output of ps -aux, in case that may hint towards something:
root@transmission_1:/var/db/transmission # ps -aux
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 11345 0.0 0.0 20448 5044 - SsJ 16:39 51:18.96 /usr/local/sbin/openvpn --cd /usr/local/etc/openvpn --daemon openvpn --config /usr/local/etc/openvpn/openvpn.conf --writepid /var/run/ope
root 64783 0.0 0.1 145036 49416 - SJ 15:36 0:08.62 /usr/pbi/transmission-amd64/bin/python2.7 /usr/pbi/transmission-amd64/control.py start 192.168.86.29 12349
root 64853 0.0 0.0 10464 2072 - SsJ 15:36 0:02.24 /usr/sbin/syslogd -s
root 64947 0.0 0.0 55676 5892 - IsJ 15:36 0:00.02 /usr/sbin/sshd
root 64951 0.0 0.0 12564 2008 - IsJ 15:36 0:00.06 /usr/sbin/cron -s
root 76061 0.0 0.0 83092 6624 - SsJ 18:06 0:00.55 sshd: root@pts/0 (sshd)
transmission 76867 0.0 0.1 105968 27400 - SsJ 18:07 22:53.91 /usr/pbi/transmission-amd64/bin/transmission-daemon -g /var/db/transmission -x /var/run/transmission/daemon.pid
root 1345 0.0 0.0 21164 2104 0 R+J 20:59 0:00.00 ps -aux
root 76064 0.0 0.0 19600 3372 0 SsJ 18:06 0:00.29 -csh (csh)
Any suggestions on this?