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