]>
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 | # |
964cdbbb | 12 | # processname: autofs |
a38f2977 | 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 | ||
d2ed1b07 | 22 | # Demon specified configuration. |
733b034a | 23 | [ -f /etc/sysconfig/autofs ] && . /etc/sysconfig/autofs |
d2ed1b07 | 24 | |
a38f2977 | 25 | # Check that networking is up. |
733b034a | 26 | if is_no "${NETWORKING}"; then |
86f60339 | 27 | # nls "ERROR: Networking is down. %s can't be run." <service> |
28 | msg_network_down automounter | |
29 | exit 1 | |
e0d6e433 | 30 | fi |
733b034a | 31 | |
d2ed1b07 | 32 | DAEMON=/usr/sbin/automount |
797fe9d4 | 33 | |
34 | # | |
35 | # This function will build a list of automount commands to execute in | |
36 | # order # to activate all the mount points. It is used to figure out | |
37 | # the difference of automount points in case of a reload | |
38 | # | |
aacfd6e1 | 39 | getmounts() |
797fe9d4 | 40 | { |
41 | # | |
2dfbde63 | 42 | # Check for local maps to be loaded |
797fe9d4 | 43 | # |
86f60339 | 44 | if [ -f /etc/autofs/auto.master ]; then |
797fe9d4 | 45 | cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| ( |
46 | while read dir map options | |
47 | do | |
48 | if [ ! -z "$dir" -a ! -z "$map" \ | |
49 | -a x`echo "$map" | cut -c1` != 'x-' ] | |
50 | then | |
2dfbde63 | 51 | map=`echo "/etc/autofs/$map" | sed -e 's:^/etc\/autofs//:/:'` |
52 | options=`echo "$options" | sed -e 's/\(^\|[ \t]\)-/\1/g'` | |
797fe9d4 | 53 | if [ -x $map ]; then |
d2ed1b07 | 54 | echo "$DAEMON --timeout $TIMEOUT $dir program $map $options" |
797fe9d4 | 55 | elif [ -f $map ]; then |
d2ed1b07 | 56 | echo "$DAEMON --timeout $TIMEOUT $dir file $map $options" |
797fe9d4 | 57 | else |
d2ed1b07 | 58 | echo "$DAEMON --timeout $TIMEOUT $dir `basename $map` $options" |
797fe9d4 | 59 | fi |
60 | fi | |
61 | done | |
62 | ) | |
63 | fi | |
64 | ||
65 | # | |
2dfbde63 | 66 | # Check for YellowPage maps to be loaded |
797fe9d4 | 67 | # |
ab90884a | 68 | if is_yes $USE_YP; then |
797fe9d4 | 69 | if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ] |
70 | then | |
71 | ypcat -k auto.master | ( | |
72 | while read dir map options | |
73 | do | |
74 | if [ ! -z "$dir" -a ! -z "$map" \ | |
75 | -a x`echo "$map" | cut -c1` != 'x-' ] | |
76 | then | |
77 | map=`echo "$map" | sed -e 's/^auto_/auto./'` | |
78 | if echo $options | grep -- '-t' >/dev/null 2>&1 ; then | |
79 | mountoptions="--timeout $(echo $options | \ | |
80 | sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')" | |
81 | fi | |
2dfbde63 | 82 | options=`echo "$options" | sed -e ' |
83 | s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g | |
84 | s/\(^\|[ \t]\)-/\1/g'` | |
d2ed1b07 | 85 | echo "$DAEMON --timeout $TIMEOUT $mountoptions $dir yp $map $options" |
797fe9d4 | 86 | fi |
87 | done | |
88 | ) | |
89 | fi | |
ab90884a | 90 | fi |
797fe9d4 | 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? |
964cdbbb | 99 | if [ ! -f /var/lock/subsys/autofs ]; then |
86f60339 | 100 | msg_starting automounter |
a38f2977 | 101 | busy |
2dfbde63 | 102 | if getmounts | sh; then |
86f60339 | 103 | deltext;ok |
2dfbde63 | 104 | else |
86f60339 | 105 | deltext;ok |
2dfbde63 | 106 | fi |
86f60339 | 107 | RETVAL=$? |
964cdbbb | 108 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/autofs |
e8a0884c | 109 | else |
86f60339 | 110 | msg_already_running automounter |
733b034a | 111 | exit 1 |
797fe9d4 | 112 | fi |
113 | ;; | |
114 | stop) | |
86f60339 | 115 | if [ -f /var/lock/subsys/autofs ]; then |
116 | msg_stopping automount -TERM | |
117 | killproc automount | |
118 | rm -f /var/lock/subsys/autofs >/dev/null 2>&1 | |
119 | else | |
120 | msg_not_running automounter | |
121 | exit 1 | |
122 | fi | |
797fe9d4 | 123 | ;; |
3478dede | 124 | restart|reload) |
aacfd6e1 | 125 | $0 stop |
126 | $0 start | |
797fe9d4 | 127 | ;; |
128 | status) | |
86f60339 | 129 | nls "Configured Mount Points:" |
797fe9d4 | 130 | getmounts |
131 | echo "" | |
86f60339 | 132 | nls "Active Mount Points:" |
aba83489 | 133 | ps axw|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | ( |
797fe9d4 | 134 | while read pid tt stat time command; do echo $command; done |
135 | ) | |
136 | ;; | |
137 | *) | |
3478dede | 138 | msg_usage "$0 {start|stop|restart|reload|status}" |
797fe9d4 | 139 | exit 1 |
140 | esac | |
141 | ||
733b034a | 142 | exit $RETVAL |