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