Pogoplug & Autofs

Autofs is able to mount drives over sshfs on the fly. This allows you to seamlessly use a drive that you’re accessing over a local network or even over an ocean.

Pogoplug is a new dropbox-like cloud storage solution. Interestingly, and unlike dropbox, they do not work by mirroring data on your local disks. This means that the storage space offered is truly additive. Much like sshfs.

So I was of course curious if I could have autofs mount pogoplug seamlessly on access. Now I’m not sure how stable the connection is, so perhaps it would be better advised to do this once at login and not worry about it. But, anyways, a pseudo working solution (it seems to hang the first time it’s accessed, but a ctrl+c will return to the terminal and it will be mounted). It would be a huge help if someone could help me figure out that last niggle.

I attempted to keep user credentials separate from the script, and currently this banks on them being stored in ~/.ssh/pogouser & ~/.ssh/pogopass.

My auto.master:
#/etc/auto.master
/mnt/pogoplug /etc/auto.pogoplugfs --timeout=300,--ghost,nodev,nosuid

my auto.pogoplugfs:
username -fstype=fuse,nonempty,rw :/usr/local/bin/pogoplug_wrapper

And finally pogoplug_wrapper, you need to put pogoplugfs in your path. I put it in /usr/local/bin. This does some minimal logging to ~/.cache/pogoplugfs.log. You can comment out any of those lines if you’re not interested.
#!/bin/bash
#pogoplug_wrapper

mkdir -p $1
mountuser=`basename $1`
mountuserhome=$(getent passwd $mountuser | cut -d: -f6)
cd $mountuserhome/.cache
echo "$mountuser:$mountuserhome" >> pogoplugfs.log
uid=`id -u $mountuser`
gid=`id -g $mountuser`
echo "" >> $mountuserhome/.cache/pogoplugfs.log
date >> $mountuserhome/.cache/pogoplugfs.log
chown $uid:$gid $1
chmod 755 $1
pogouser=`head -n 1 $mountuserhome/.ssh/pogouser`
pogopass=`head -n 1 $mountuserhome/.ssh/pogopass`
mountcommand="pogoplugfs --mountpoint $1 --user $pogouser --password $pogopass --fuseopts $3"
echo "$mountcommand" >> $mountuserhome/.cache/pogoplugfs.log
sudo -u $mountuser $mountcommand &
sleep 3 # give the command time to finish
exit 0

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: