Here's a BASH script I wrote used to mount with sshfs on Mac OS X Leopard.
If you wanted to use this on another OS with BASH, you'd probably just have to look at the lines output by the mount command, and modify the grep portion of the script. That's how I determine whether or not a directory is mounted. Probably not the best way, but it works.
#!/bin/bash
mounts="/Users/username/mounts";
sshfs="/Users/username/bin/sshfs";
###
# Functions
###
function createmount {
remotemountpoint=$1;
localmountpoint=$2;
if [ ! -e ${localmountpoint} ]; then
echo "mkdir ${localmountpoint}";
mkdir ${localmountpoint};
fi
if ! mount | grep "${localmountpoint}.*fusefs" >> /dev/null; then
echo "Would you like me to mount ${localmountpoint}? y/[n]";
read answer;
if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
echo "${sshfs} ${remotemountpoint} ${localmountpoint}";
$sshfs ${remotemountpoint} ${localmountpoint};
fi
fi
}
function doumount {
localmountpoint=$1;
if mount | grep "${localmountpoint}.*fusefs" >> /dev/null; then
echo "Would you like me to umount ${localmountpoint}? [y]/n";
read answer;
if [ "${answer}" == "y" ] || [ "${answer}" == "" ]; then
echo "umount ${localmountpoint}";
umount ${localmountpoint};
fi
fi
}
###
# Actions
###
if [ "${1}" == "umount" ]; then
doumount ${mounts}/mountpoint1;
doumount ${mounts}/mountpoint2;
doumount ${mounts}/mountpoint3;
exit 0;
fi
if [ ! -e ${mounts} ]; then
echo "mkdir ${mounts}";
mkdir ${mounts};
fi
### create mountpoint1
createmount user@host:/path/to/remote/mountpoint1 ${mounts}/mountpoint1;
### create mountpoint2
createmount user@host:/path/to/remote/mountpoint2 ${mounts}/mountpoint2;
### create mountpoint3
createmount user@host:/path/to/remote/mountpoint3 ${mounts}/mountpoint3;
Also see Mac OS X notes.
[Click to add or edit comments])
Please prepend comments below including a date