| 192 |
- |
1 |
#!/bin/bash
|
|
|
2 |
|
|
|
3 |
# This file must be executable to work! chmod 755!
|
|
|
4 |
|
|
|
5 |
# Look at what a host is exporting to determine what we can mount.
|
|
|
6 |
# This is very simple, but it appears to work surprisingly well
|
|
|
7 |
|
|
|
8 |
key="$1"
|
|
|
9 |
|
|
|
10 |
# add "nosymlink" here if you want to suppress symlinking local filesystems
|
|
|
11 |
# add "nonstrict" to make it OK for some filesystems to not mount
|
|
|
12 |
opts="-fstype=nfs,hard,intr,nodev,nosuid"
|
|
|
13 |
|
|
|
14 |
for P in /bin /sbin /usr/bin /usr/sbin
|
|
|
15 |
do
|
|
|
16 |
for M in showmount kshowmount
|
|
|
17 |
do
|
|
|
18 |
if [ -x $P/$M ]
|
|
|
19 |
then
|
|
|
20 |
SMNT=$P/$M
|
|
|
21 |
break 2
|
|
|
22 |
fi
|
|
|
23 |
done
|
|
|
24 |
done
|
|
|
25 |
|
|
|
26 |
[ -x $SMNT ] || exit 1
|
|
|
27 |
|
|
|
28 |
# Newer distributions get this right
|
|
|
29 |
SHOWMOUNT="$SMNT --no-headers -e $key"
|
|
|
30 |
|
|
|
31 |
$SHOWMOUNT | LC_ALL=C cut -d' ' -f1 | LC_ALL=C sort -u | \
|
|
|
32 |
awk -v key="$key" -v opts="$opts" -- '
|
|
|
33 |
BEGIN { ORS=""; first=1 }
|
|
|
34 |
{ if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 }
|
|
|
35 |
END { if (!first) print "\n"; else exit 1 }
|
|
|
36 |
' | sed 's/#/\\#/g'
|