~ubuntu-branches/ubuntu/natty/autofs5/natty-proposed

« back to all changes in this revision

Viewing changes to samples/auto.net

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-04-28 15:55:37 UTC
  • Revision ID: james.westby@ubuntu.com-20080428155537-h6h457h1fwwzhvby
Tags: upstream-5.0.3
ImportĀ upstreamĀ versionĀ 5.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
# Showmount comes in a number of names and varieties.  "showmount" is
 
15
# typically an older version which accepts the '--no-headers' flag
 
16
# but ignores it.  "kshowmount" is the newer version installed with knfsd,
 
17
# which both accepts and acts on the '--no-headers' flag.
 
18
#SHOWMOUNT="kshowmount --no-headers -e $key"
 
19
#SHOWMOUNT="showmount -e $key | tail -n +2"
 
20
 
 
21
for P in /bin /sbin /usr/bin /usr/sbin
 
22
do
 
23
        for M in showmount kshowmount
 
24
        do
 
25
                if [ -x $P/$M ]
 
26
                then
 
27
                        SMNT=$P/$M
 
28
                        break
 
29
                fi
 
30
        done
 
31
done
 
32
 
 
33
[ -x $SMNT ] || exit 1
 
34
 
 
35
# Newer distributions get this right
 
36
SHOWMOUNT="$SMNT --no-headers -e $key"
 
37
 
 
38
$SHOWMOUNT | LC_ALL=C sort -k 1 | \
 
39
        awk -v key="$key" -v opts="$opts" -- '
 
40
        BEGIN   { ORS=""; first=1 }
 
41
                { if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 }
 
42
        END     { if (!first) print "\n"; else exit 1 }
 
43
        ' | sed 's/#/\\#/g'