Miklos Szeredi | ea18d11 | 2005-06-27 13:05:49 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # FUSE mount helper |
| 4 | # Petr Klima <qaxi@seznam.cz> |
| 5 | # Thanks to Miklos Szeredi <miklos@szeredi.hu> |
| 6 | # to kick me to the right way |
| 7 | # |
| 8 | |
| 9 | VERSION="0.0.1" |
| 10 | PRGNAME=`basename $0` |
| 11 | |
| 12 | USAGE="${PRGNAME} version ${VERSION} |
| 13 | usage: ${PRGNAME} fusefs_type#[mountpath] mountpoint [FUSE options] |
| 14 | |
| 15 | example: ${PRGNAME} sshfs#root@tux:/ /mnt/tuxssh -o rw |
| 16 | " |
| 17 | |
| 18 | function die { |
| 19 | echo -e "$PRGNAME# $1" >&2 |
| 20 | [ -z "$2" ] && exit 128 |
| 21 | exit "$2" |
| 22 | } |
| 23 | |
| 24 | [ "$#" -ge 2 ] || die "${USAGE}" |
| 25 | |
| 26 | FSTYPE=${1%%\#*} # for now i have to be same as FUSE mount binary |
| 27 | # should be configurable |
| 28 | |
Miklos Szeredi | f194147 | 2006-01-02 16:27:48 +0000 | [diff] [blame] | 29 | export PATH |
Miklos Szeredi | ea18d11 | 2005-06-27 13:05:49 +0000 | [diff] [blame] | 30 | FSBIN=`which ${FSTYPE} 2>/dev/null` \ |
| 31 | || die "Can not find FUSE mount binary for FS ${FSTYPE}" 1 |
| 32 | |
| 33 | MOUNTPATH=${1#*#} |
| 34 | |
| 35 | # was there an # in $1 |
| 36 | [ "$1" = "$MOUNTPATH" ] && MOUNTPATH="" |
| 37 | |
| 38 | MOUNTPOINT="$2" |
| 39 | [ -d "${MOUNTPOINT}" ] || die "Directory ${MOUNTPOINT} does not exist" |
| 40 | |
| 41 | shift |
| 42 | shift |
| 43 | |
Miklos Szeredi | b32c79b | 2006-01-09 11:14:29 +0000 | [diff] [blame] | 44 | ignore_opts="(user|nouser|users|auto|noauto|_netdev)" |
| 45 | |
| 46 | OPTIONS=`echo $@ | sed -r "s/(,${ignore_opts}|${ignore_opts},)//g"` |
Miklos Szeredi | ea18d11 | 2005-06-27 13:05:49 +0000 | [diff] [blame] | 47 | |
Miklos Szeredi | ea18d11 | 2005-06-27 13:05:49 +0000 | [diff] [blame] | 48 | ${FSTYPE} ${MOUNTPATH} ${MOUNTPOINT} ${OPTIONS} |