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