]> code.delx.au - monosys/blob - scripts/mount.fuse
75d21bf37bb50b4b9292837869c6c7b3d3ac63f5
[monosys] / scripts / mount.fuse
1 #!/bin/bash
2 #
3 # FUSE mount helper
4 # Petr Klima <qaxi@seznam.cz>
5 # James Bunton <jamesbunton@fastmail.fm>
6 # Thanks to Miklos Szeredi <miklos@szeredi.hu>
7 # to kick me to the right way
8 #
9
10 VERSION="0.0.2"
11 PRGNAME=`basename $0`
12 HOME=/root
13
14 USAGE="${PRGNAME} version ${VERSION}
15 usage: ${PRGNAME} fusefs_type#[mountpath] mountpoint [FUSE options]
16
17 example: ${PRGNAME} sshfs#root@tux:/ /mnt/tuxssh -o rw
18 "
19
20 function die {
21 echo -e "$PRGNAME# $1" >&2
22 [ -z "$2" ] && exit 128
23 exit "$2"
24 }
25
26 [ "$#" -ge 2 ] || die "${USAGE}"
27
28 FSTYPE=${1%%\#*} # for now i have to be same as FUSE mount binary
29 # should be configurable
30
31 export PATH
32 FSBIN=`which ${FSTYPE} 2>/dev/null` \
33 || die "Can not find FUSE mount binary for FS ${FSTYPE}" 1
34
35 MOUNTPATH=${1#*#}
36
37 # was there an # in $1
38 [ "$1" = "$MOUNTPATH" ] && MOUNTPATH=""
39
40 MOUNTPOINT="$2"
41 [ -d "${MOUNTPOINT}" ] || die "Directory ${MOUNTPOINT} does not exist"
42
43 shift
44 shift
45 shift
46
47 ignore_opts="(user|nouser|users|auto|noauto|_netdev)"
48
49 OPTIONS=`echo $@ | sed -r "s/(,${ignore_opts}|${ignore_opts},)//g"`
50 NEWOPTIONS=""
51 OLDIFS="${IFS}"
52 IFS=','
53 for opt in ${OPTIONS}; do
54 NEWOPTIONS="${NEWOPTIONS} -o ${opt}"
55 done
56 IFS="${OLDIFS}"
57
58 ${FSTYPE} ${MOUNTPATH} ${MOUNTPOINT} ${NEWOPTIONS}