]> git.pld-linux.org Git - packages/autofs.git/blame - autofs.init
- fix in checking is netforking is up.
[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#
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
22# Get service config
23[ -f /etc/sysconfig/inetd ] && . /etc/sysconfig/inetd
24
25# Check that networking is up.
e0d6e433 26if [ "${NETWORKING}" = "no" ]; then
27 echo "WARNING: Networking is down. Autofs service can't be runed."
28 exit 1
29fi
a38f2977 30
797fe9d4 31
797fe9d4 32# We can add local options here
33# e.g. localoptions='rsize=8192,wsize=8192'
34#
35localoptions=''
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#
45# Check for local maps to be loaded
46#
47if [ -f /etc/autofs/auto.master ]
48then
49 cat /etc/autofs/auto.master | sed -e '/^#/d' -e '/^$/d'| (
50 while read dir map options
51 do
52 if [ ! -z "$dir" -a ! -z "$map" \
53 -a x`echo "$map" | cut -c1` != 'x-' ]
54 then
55 map=`echo "/etc/autofs/$map" | sed -e 's:^/etc/autofs/:/:'`
56 # special: treat -t or --timeout (or any reasonable derivative)
57 # specially, since it can't be made a normal mount option.
58 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
59 mountoptions="--timeout $(echo $options | \
60 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
61 fi
62 options=`echo "$options" | sed -e '
63 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
64 s/\(^\|[ \t]\)-/\1/g'`
65 if [ -x $map ]; then
66 echo "/usr/sbin/automount $mountoptions $dir program $map $options $localoptions"
67 elif [ -f $map ]; then
68 echo "/usr/sbin/automount $mountoptions $dir file $map $options $localoptions"
69 else
70 echo "/usr/sbin/automount $mountoptions $dir `basename $map` $options $localoptions"
71 fi
72 fi
73 done
74 )
75fi
76
77#
78# Check for YellowPage maps to be loaded
79#
80if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
81then
82 ypcat -k auto.master | (
83 while read dir map options
84 do
85 if [ ! -z "$dir" -a ! -z "$map" \
86 -a x`echo "$map" | cut -c1` != 'x-' ]
87 then
88 map=`echo "$map" | sed -e 's/^auto_/auto./'`
89 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
90 mountoptions="--timeout $(echo $options | \
91 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
92 fi
93 options=`echo "$options" | sed -e '
94 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
95 s/\(^\|[ \t]\)-/\1/g'`
96 echo "/usr/sbin/automount $mountoptions $dir yp $map $options $localoptions"
97 fi
98 done
99 )
100fi
101}
102
103#
104# See how we were called.
105#
106case "$1" in
107 start)
a38f2977 108 # Check if the service is already running?
797fe9d4 109 if [ ! -f /var/lock/subsys/automount ]; then
a38f2977 110 show Starting automounter
111 busy
112 getmounts | sh
113 deltext
114 ok
e8a0884c 115 else
a38f2977 116 echo "automount already is running"
797fe9d4 117 fi
a38f2977 118 touch /var/lock/subsys/automount
797fe9d4 119 ;;
120 stop)
121 show Stopping automounter
7bb2308b 122 killproc automount -TERM
797fe9d4 123 rm -f /var/lock/subsys/automount
797fe9d4 124 ;;
aacfd6e1 125 restart|reload)
797fe9d4 126 if [ ! -f /var/lock/subsys/automount ]; then
127 echo "Automounter not running"
128 exit 1
129 fi
aacfd6e1 130 $0 stop
131 $0 start
797fe9d4 132 ;;
133 status)
134 echo "Configured Mount Points:"
135 getmounts
136 echo ""
137 echo "Active Mount Points:"
138 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
139 while read pid tt stat time command; do echo $command; done
140 )
141 ;;
142 *)
143 echo "Usage: $0 {start|stop|restart|reload|status}"
144 exit 1
145esac
146
147exit 0
This page took 0.077215 seconds and 4 git commands to generate.