If you have setup Transmission on your Pogoplug using my previous post, then this post will allow you to remotely (via my.pogoplug.com) add new torrent files and start them downloading to your home server.
I’ve been looking for a secure way to add Torrents to my Transmission server running on my Pogoplug, from a remote location. This would allow me to start new torrents (during my lunchbreak at work for example), and have them finished and ready for me by the time I got home. This is handy for starting larger files, such as new Ubuntu releases (and recently, the Microsoft Windows 8 Consumer Preview), without having to be in your local network,
Initially, I put the Transmission web interface on a public IP, but I’m not particularly comfortable with opening extra ports from my LAN to the internet, so I soon switched this off. This morning I hacked together a solution that utilises the security that already exists with my.pogoplug.com (SSL, username/password authentication), and allows for adding a torrent file.
It works as follows:
- You upload your selected .torrent file to a folder via my.pogoplug.com
- A scheduled task (cronjob) checks the folder for new torrent files at a set interval (e.g. every 5 minutes)
- If the scheduled task finds any new torrents, it adds them to the local Transmission server, then removes the .torrent file from disk
- When you get home, your torrent is (hopefully) finished and ready for you. Simple 🙂
- Log in to my.pogoplug.com
- Select the drive that you would like to use for temporarily storing .torrent files, and create a folder names “Torrents” in the root of the drive:
- SSH onto your pogoplug and perform the following:
# create the required crontab directory on our flash drive mkdir -p /opt/var/spool/cron/crontabs # link from the main drive to our flash ln -s /opt/var/spool /var/spool # create the transmission scheduler script touch /opt/bin/transmission-scheduler.sh vi /opt/bin/transmission-scheduler.sh
The next bit involves a little editing before we can copy and paste as the contents of the transmission-scheduler.sh script. There are two variables at the top of this script that you will need to customise before this script will work – “pathToTorrentFolder” and “transmissionUrl”.
pathToTorrentFolder should be set to the filesystem path of your Torrent folder. Use the output of “df -h” to find yours – my drive is mounted to “/tmp/.cemnt/mnt_sda1/” so my Torrents folder is “/tmp/.cemnt/mnt_sda1/Torrents/”.
transmissionUrl should be set to your Transmission web interface url. For example, mine is “http://192.168.0.10:9091/transmission”. It is really important that you follow the same format (“/transmission” at the end). And make sure to have no trailing slash.
Now copy and paste the following script into the terminal (with YOUR custom variable values instead of mine 🙂 ):
#!/bin/sh pathToTorrentFolder='/tmp/.cemnt/mnt_sda1/Torrents/' transmissionUrl='http://192.168.0.10:9091/transmission' for f in $pathToTorrentFolder*.torrent ; do /opt/bin/transmission-remote $transmissionUrl -a "$f"; rm "$f"; done
Save the file and exit Vi. Now continue executing the following in the terminal:
# give execute permission on the scheduler script chmod +x /opt/bin/transmission-scheduler.sh # add a crontab entry to run the script at a specified interval crontab -e
Paste the following in, substituting “5” with your desired interval check (in minutes).
*/5 * * * * /opt/bin/transmission-scheduler.sh
Save the file and exit Vi.
Now continue in the terminal with the following:
# start the cron daemon
That should be it!
To test, grab a torrent file (may I suggest the Wired Magazine CC CD – http://www.clearbits.net/torrents/63-wired-magazine-creative-commons-cd), download it to your computer, then upload via my.pogoplug.com to your Torrents folder.
Go make a cup of tea, and by the time you come back, check the Transmission web interface. If everything has gone to plan, Transmission is downloading the torrent and the .torrent file should have been deleted from the Torrents folder.
Any questions, give me a shout in the comments section.