So I've set up transmission (the torrent app) to run a script on my torrent to automagically move my torrents and create symlinks to them. This is the script:
#!/bin/bash
curl -d "email=email.address@gmail.com" \
-d "¬ification[from_screen_name]=$TR_TORRENT_NAME" \
-d "¬ification[message]=Torrent has finished downloading." \
http://boxcar.io/devices/providers/key/notifications;
tid=$TR_TORRENT_ID
name=$TR_TORRENT_NAME
hash=$TR_TORRENT_HASH
echo -e "checked $tid - $name - $hash \n" >> /home/wouter/Apps/transmission/logfile
antwoord=$(php /home/wouter/Apps/transmission/determineaction.php $tid $hash 2> /dev/null);
echo $antwoord >> /home/wouter/Apps/transmission/logfile
actie=${antwoord:0:1}
torrentid=${antwoord:1}
echo -e "actie $actie - btnid $torrentid \n" >> /home/wouter/Apps/transmission/logfile
if [ $actie != 0 ]; then
antwoord=$(php /home/wouter/Apps/transmission/returnfolder.php $torrentid 2> /dev/null);
seizoen=${antwoord:0:2}
serie=${antwoord:2}
seizoen=$((10#$seizoen))
echo -e "serie $serie - seizoen $seizoen \n" >> /home/wouter/Apps/transmission/logfile
mkdir -p "/mnt/hdd3/Series/$serie/Season $seizoen"
if [ $actie = 2 ]; then
transmission-remote -t$tid --auth=wouter:neirod --move "/mnt/hdd3/Torrents/Broadcasthenet/Downloads"
fi
ext=$(echo $name | tail -c 5)
linknaam=$(php /home/wouter/Apps/transmission/returnname.php $torrentid 2> /dev/null)
echo -e "extensie $ext - linknaam $linknaam \n" >> /home/wouter/Apps/transmission/logfile
if [ $ext = ".mkv" ]; then
ln -s "../../../Torrents/Broadcasthenet/Downloads/$name" "/mnt/hdd3/Series/$serie/Season $seizoen/$linknaam" 2> /home/wouter/Apps/transmission/error
else
ln -s "../../../Torrents/Broadcasthenet/Downloads/$name/*.mkv" "/mnt/hdd3/Series/$serie/Season $seizoen/$linknaam"
fi
fi
As you can see I've built in some logs to check where things go wrong. Everything goes well until the creation of the symbolic link. There the code spawns this error
ln: accessing `/mnt/hdd3/Series/Revenge/Season 2/Revenge - S02E09 - Revelations.mkv': Permission denied
I think transmission executes the script as user 'debian-transmission', so I've tried to execute it with this user. No errors.
I tried giving 777 permissions to the destination folder. This doesn't solve anything.
Why do I get a 'permission denied' and how can I solve it?
ls -ld "/mnt/hdd3/Series/Revenge/Season 2/",ls -l "/mnt/hdd3/Series/Revenge/Season 2/", andls -ld ../../../Torrents/Broadcasthenet/Downloads/*. – Flimm Jan 4 at 15:07echo $(whoami) > /tmp/whoto know which user run script – ubuntufan Jan 4 at 15:18drwxrwxrw- 2 plex familie 4096 jan 4 15:23 /mnt/hdd3/Series//Revenge//Season 2/– vixducis Jan 4 at 19:03lrwxrwxrwx 1 plex familie 92 jan 2 15:23 Revenge - S02E01 - Destiny.mkv -> ../../../Torrents/Broadcasthenet/Downloads/Revenge.S02E01.1080p.WEB-DL.DD5.1.H.264-KiNGS.mkv lrwxrwxrwx 1 debian-transmission debian-transmission 92 jan 4 14:18 Revenge - S02E06 - Illusion.mkv -> ../../../Torrents/Broadcasthenet/Downloads/Revenge.S02E06.1080p.WEB-DL.DD5.1.H.264-KiNGS.mkv lrwxrwxrwx 1 debian-transmission debian-transmission 92 jan 4 14:46 Revenge - S02E07 - Penance.mkv -> ../../../Torrents/Broadcasthenet/Downloads/Revenge.S02E07.1080p.WEB-DL.DD5.1.H.264-KiNGS.mkv– vixducis Jan 4 at 19:10