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.
/mnt/pogoplug /etc/auto.pogoplugfs --timeout=300,--ghost,nodev,nosuid
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.
mkdir -p $1
mountuserhome=$(getent passwd $mountuser | cut -d: -f6)
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