forked from facebookarchive/nfusr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mount.nfusr.in
executable file
·50 lines (40 loc) · 996 Bytes
/
mount.nfusr.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
NFUSR="@bindir@/nfusr"
function usage() {
echo "Usage: $0 <host> <mountpoint> [-o mount-option[,mount-option...]]"
echo ""
echo "Where <host> is a set of NFS hosts, expressed as 'nfs://host/export[,nfs://host/export...]'."
exit 1
}
# Parse the 'host' command line argument, return a set of NFS hosts in $HOSTS global.
function get_hosts () {
local HOST=$1
if [[ "$HOST" =~ ^nfs://.* ]]; then
HOSTS=$(echo "$HOST" | sed 's/,/ /g')
else
echo "Invalid host specifier: $HOST."
usage
return 1
fi
return 0
}
if [ $# -lt 2 ]; then
usage
fi
if ! get_hosts "$1"; then
exit 1
fi
mountpoint=$2
shift 2
mountopts=""
while getopts "so:" opt; do
if [ "$opt" = "o" ]; then
for option in $(echo "$OPTARG" | sed 's/,/ /g'); do
mountopts="$mountopts,$option"
done
fi
done
if [ -n "$mountopts" ]; then
mountopts=$(echo "$mountopts" | sed 's/^,/-o /')
fi
$NFUSR $HOSTS $mountpoint $mountopts