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