-
Notifications
You must be signed in to change notification settings - Fork 55
/
auto.diod.in
executable file
·50 lines (47 loc) · 1.45 KB
/
auto.diod.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
#
# auto.diod - executable automounter map for diod file systems
#
# Input: $1 is "key" (/d/key is accessed)
# Output: string of the form "-fstype=diod server:path" on stdout
# Stderr goes to the system logs
# See autofs(5)
#
key="$1"
[ -n "$key" ] || exit 0
DIOD_MAP=/d
DIOD_SYSCONF=@X_SYSCONFDIR@/sysconfig/auto.diod
DIOD_DIODCAT=@X_SBINDIR@/diodcat
DIOD_SERVERS=""
DIOD_TIMEOUT=10
if [ -r $DIOD_SYSCONF ]; then
. $DIOD_SYSCONF
fi
if [ -z "$DIOD_SERVERS" ]; then
echo "auto.diod: DIOD_SERVERS is not set" >&2
exit 1
fi
if ! [ -x $DIOD_DIODCAT ]; then
echo "auto.diod: could not execute $DIOD_DIODCAT" >&2
exit 1
fi
for server in $DIOD_SERVERS; do
host=`echo $server | awk -F: '{print $1}'`
port=`echo $server | awk -F: '{print $2}'`
$DIOD_DIODCAT ${port:+-p $port} ${DIOD_TIMEOUT:+-t $DIOD_TIMEOUT} \
-h $host exports | awk '{print $1}' |\
while read path; do
if [ "$path" == "/" ]; then
if [ "$key" == "ROOT" ]; then
echo "-fstype=diod${port:+,port=$port} $host:$path"
exit 0
fi
elif [ "$key" == "$(echo $path|sed -e's/^\///' -e's/\//./g')" ] \
|| [ "$key" == "$(echo $path|sed -e's/^\///' -e's/\//_/g')" ] \
|| [ "$key" == "$(echo $path|sed -e's/^\///' -e's/\//-/g')" ] \
|| [ "$key" == "$(basename $path)" ]; then
echo "-fstype=diod${port:+,port=$port} $host:$path"
exit 0
fi
done
done