jump to navigation

Adding Bittorrent Support to My PogoPlug February 12, 2014

Posted by samwyse in Scripting.
trackback

Over the weekend, I visited my local Walmart and found a Pogoplug model V4-A1-01 in the electronics section. It was on the discontinued items table and marked down to $39.95, about half of what it cost new, but still a bit more that what you could find online. Still, a bird in the hand, etc. I took it home and plugged in a 1TB external drive that I’ve had for a couple of years, and it worked perfectly. Then I decided to try installing a Bittorrent client.

After a bit of a search, I found some instructions (each part is linked below) at Aaron Randall’s blog, but they are for an older version and needed some adapting to work on my Pogoplug. Here are my revisions:

Part 1, Step 1: Preparing Your Pogoplug — Unchanged.

Part 1, Step 2: Checking the Filesystem — My system has a /dev/mtdblock3 file, but I couldn’t mount anything on it. Instead I inserted an old 1GB SD card that I reformatted to use the ext3 filesystem. Instead of mounting it myself, I created a symbolic link.

mount -o remount,rw /
ln -s /opt /tmp/.cemnt/mnt_mmcblk0p1

Part 1, Step 3: Installing a Package Management System — Unchanged.

Part 2, Steps 1-3: Unchanged.

Part 2, Step 4: Running the Bittorent Client — Unchanged, except Aaron just shows you how to start the daemon manually. This means that if there’s a power outage, the daemon won’t restart automatically. I’ll fix that below.

Part 3: Adding Torrents via my.pogoplug.com — This is where everything is different. After I installed the ipkg version of cron, I couldn’t get it to work. After several hours of trying, I removed the package and used the busybox crond that is already installed on the Pogoplug. First, I set everything up so that both crond and the daemon would restart. I did this by appending the following to the /etc/init.d/rcS script:

# wait for the SD card to get mounted, then remount it with 'exec'
while ! mount -o remount,exec /tmp/.cemnt/mmcblk0p1
do sleep 1
done
# now we can start the daemon
/opt/bin/transmission-daemon --config-dir /opt/config/transmission-daemon/
# recreate our crontab
mkdir -p /var/spool/cron/crontabs
cp /etc/crontab /var/spool/cron/crontabs/root
# start crond
/usr/sbin/crond

There’s another process that mounts all external storage at boot time, but it does so using the ‘noexec’ option. So I remount it using the ‘exec’ flag. But that won’t work if the other process isn’t done, so I do the remount in a loop with a one second delay. Also, /var is a symbolic link to /tmp/var, so everything there gets erased at every reboot. I had an earlier /etc/crontab left over from my experimentation, so I just copy it over; if I were doing everything from scratch, I’d probably put the source file somewhere in /opt. /etc/crontab just has one line: */15 * * * * /opt/bin/transmission-scheduler.sh This runs the scheduler every fifteen minutes, which is find for me. The scheduler script looks like this:

#!/bin/sh
pathToTorrentFolder='/tmp/.cemnt/mnt_sda1/Torrents'
for f in $pathToTorrentFolder/*.torrent ;
do
[ -f $f ] && /opt/bin/transmission-remote -a "$f" && rm "$f";
done
/opt/bin/transmission-remote -l > $pathToTorrentFolder/transmission.log

Most of the time, the way that file name expansion works means that the $f variable will contain /tmp/.cemnt/mnt_sda1/Torrents/*.torrent so I first verify that the named file actually exists. If so, I add the torrent; and only if that is successful do I remove the file. Finally, I list all active torrents in a log file, so I can check on things without needing to SSH into the Pogoplug.

Advertisements

Comments»

1. Jim - August 13, 2014

Thanks for the nice tutorial. I do have two questions if you could clear up:
1) why you copy to “…./root” directory, I thought just “/var…/crontab” will be fine?

2) Not quite understand your “transmission-scheduler.sh”, no need to define “transmissionUrl”, like Randall blog did.

Thank you

2. ratliffhines24216 - April 8, 2016

We are doing the same in here in my room. By Sunday we cant even place our hand there, ther will be no place. Then, wash them all in once stretch. Next day morning, atleast one cup and a spoon in the sink again.https://ameo.link/ratliffhines24216081815


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: