]>
Commit | Line | Data |
---|---|---|
32959511 | 1 | #!/bin/sh |
797fe9d4 | 2 | # |
3 | # $Id$ | |
4 | # | |
5 | # /etc/rc.d/init.d/autofs | |
6 | # | |
7 | # rc file for automount using a Sun-style "master map". | |
15074ac4 | 8 | # We first look for a local /etc/autofs/auto.master, then a YP |
797fe9d4 | 9 | # map with that name |
10 | # | |
aacfd6e1 | 11 | # chkconfig: 2345 72 08 |
797fe9d4 | 12 | # description: automatically mounts filesystems when you use \ |
13 | # them, and unmounts them later when you are not using them. | |
14 | # processname: automount | |
15 | # Note that there may be multiple processes names automount | |
15074ac4 | 16 | # config: /etc/autofs/auto.master |
797fe9d4 | 17 | # Note that all other config files are automatically reloaded |
18 | # and may be different on different systems; we can ignore them | |
19 | # here | |
20 | ||
21 | # Source function library. | |
22 | . /etc/rc.d/init.d/functions | |
23 | ||
24 | [ -f /usr/sbin/automount ] || exit 0 | |
25 | ||
26 | # | |
27 | # We can add local options here | |
28 | # e.g. localoptions='rsize=8192,wsize=8192' | |
29 | # | |
30 | localoptions='' | |
31 | ||
32 | # | |
33 | # This function will build a list of automount commands to execute in | |
34 | # order # to activate all the mount points. It is used to figure out | |
35 | # the difference of automount points in case of a reload | |
36 | # | |
aacfd6e1 | 37 | getmounts() |
797fe9d4 | 38 | { |
39 | # | |
40 | # Check for local maps to be loaded | |
41 | # | |
42 | if [ -f /etc/autofs/auto.master ] | |
43 | then | |
44 | cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| ( | |
45 | while read dir map options | |
46 | do | |
47 | if [ ! -z "$dir" -a ! -z "$map" \ | |
48 | -a x`echo "$map" | cut -c1` != 'x-' ] | |
49 | then | |
50 | map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs/:/:'` | |
51 | # special: treat -t or --timeout (or any reasonable derivative) | |
52 | # specially, since it can't be made a normal mount option. | |
53 | if echo $options | grep -- '-t' >/dev/null 2>&1 ; then | |
54 | mountoptions="--timeout $(echo $options | \ | |
55 | sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')" | |
56 | fi | |
57 | options=`echo "$options" | sed -e ' | |
58 | s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g | |
59 | s/\(^\|[ \t]\)-/\1/g'` | |
60 | if [ -x $map ]; then | |
61 | echo "/usr/sbin/automount $mountoptions $dir program $map $options $localoptions" | |
62 | elif [ -f $map ]; then | |
63 | echo "/usr/sbin/automount $mountoptions $dir file $map $options $localoptions" | |
64 | else | |
65 | echo "/usr/sbin/automount $mountoptions $dir `basename $map` $options $localoptions" | |
66 | fi | |
67 | fi | |
68 | done | |
69 | ) | |
70 | fi | |
71 | ||
72 | # | |
73 | # Check for YellowPage maps to be loaded | |
74 | # | |
75 | if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ] | |
76 | then | |
77 | ypcat -k auto.master | ( | |
78 | while read dir map options | |
79 | do | |
80 | if [ ! -z "$dir" -a ! -z "$map" \ | |
81 | -a x`echo "$map" | cut -c1` != 'x-' ] | |
82 | then | |
83 | map=`echo "$map" | sed -e 's/^auto_/auto./'` | |
84 | if echo $options | grep -- '-t' >/dev/null 2>&1 ; then | |
85 | mountoptions="--timeout $(echo $options | \ | |
86 | sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')" | |
87 | fi | |
88 | options=`echo "$options" | sed -e ' | |
89 | s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g | |
90 | s/\(^\|[ \t]\)-/\1/g'` | |
91 | echo "/usr/sbin/automount $mountoptions $dir yp $map $options $localoptions" | |
92 | fi | |
93 | done | |
94 | ) | |
95 | fi | |
96 | } | |
97 | ||
98 | # | |
99 | # See how we were called. | |
100 | # | |
101 | case "$1" in | |
102 | start) | |
103 | # Check if the automounter is already running? | |
104 | if [ ! -f /var/lock/subsys/automount ]; then | |
105 | show Starting automounter | |
106 | busy | |
107 | getmounts | sh | |
108 | touch /var/lock/subsys/automount | |
109 | deltext | |
110 | ok | |
e8a0884c | 111 | else |
112 | echo "Automounter already is running" | |
797fe9d4 | 113 | fi |
114 | ;; | |
115 | stop) | |
116 | show Stopping automounter | |
7bb2308b | 117 | killproc automount -TERM |
797fe9d4 | 118 | rm -f /var/lock/subsys/automount |
797fe9d4 | 119 | ;; |
aacfd6e1 | 120 | restart|reload) |
797fe9d4 | 121 | if [ ! -f /var/lock/subsys/automount ]; then |
122 | echo "Automounter not running" | |
123 | exit 1 | |
124 | fi | |
aacfd6e1 | 125 | $0 stop |
126 | $0 start | |
797fe9d4 | 127 | ;; |
128 | status) | |
129 | echo "Configured Mount Points:" | |
130 | getmounts | |
131 | echo "" | |
132 | echo "Active Mount Points:" | |
133 | ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | ( | |
134 | while read pid tt stat time command; do echo $command; done | |
135 | ) | |
136 | ;; | |
137 | *) | |
138 | echo "Usage: $0 {start|stop|restart|reload|status}" | |
139 | exit 1 | |
140 | esac | |
141 | ||
142 | exit 0 |