]> git.pld-linux.org Git - packages/autofs.git/blame - autofs.init
- support for autofs.sysconfig
[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
d2ed1b07 22# Demon specified configuration.
23. /etc/sysconfig/autofs
24
a38f2977 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
d2ed1b07 31DAEMON=/usr/sbin/automount
797fe9d4 32
33#
34# This function will build a list of automount commands to execute in
35# order # to activate all the mount points. It is used to figure out
36# the difference of automount points in case of a reload
37#
aacfd6e1 38getmounts()
797fe9d4 39{
40#
2dfbde63 41# Check for local maps to be loaded
797fe9d4 42#
43if [ -f /etc/autofs/auto.master ]
44then
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 )
63fi
64
65#
2dfbde63 66# Check for YellowPage maps to be loaded
797fe9d4 67#
68if [ -e /usr/bin/ypcat ] && [ `ypcat -k auto.master 2>/dev/null | wc -l` -gt 0 ]
69then
70 ypcat -k auto.master | (
71 while read dir map options
72 do
73 if [ ! -z "$dir" -a ! -z "$map" \
74 -a x`echo "$map" | cut -c1` != 'x-' ]
75 then
76 map=`echo "$map" | sed -e 's/^auto_/auto./'`
77 if echo $options | grep -- '-t' >/dev/null 2>&1 ; then
78 mountoptions="--timeout $(echo $options | \
79 sed 's/^.*-t\(imeout\)*[ \t]*\([0-9][0-9]*\).*$/\2/g')"
80 fi
2dfbde63 81 options=`echo "$options" | sed -e '
82 s/--*t\(imeout\)*[ \t]*[0-9][0-9]*//g
83 s/\(^\|[ \t]\)-/\1/g'`
d2ed1b07 84 echo "$DAEMON --timeout $TIMEOUT $mountoptions $dir yp $map $options"
797fe9d4 85 fi
86 done
87 )
88fi
89}
90
91#
92# See how we were called.
93#
94case "$1" in
95 start)
a38f2977 96 # Check if the service is already running?
797fe9d4 97 if [ ! -f /var/lock/subsys/automount ]; then
a38f2977 98 show Starting automounter
99 busy
2dfbde63 100 if getmounts | sh; then
101 deltext;ok
102 else
103 deltext;ok
104 fi
e8a0884c 105 else
a38f2977 106 echo "automount already is running"
797fe9d4 107 fi
a38f2977 108 touch /var/lock/subsys/automount
797fe9d4 109 ;;
110 stop)
111 show Stopping automounter
7bb2308b 112 killproc automount -TERM
797fe9d4 113 rm -f /var/lock/subsys/automount
797fe9d4 114 ;;
aacfd6e1 115 restart|reload)
797fe9d4 116 if [ ! -f /var/lock/subsys/automount ]; then
117 echo "Automounter not running"
118 exit 1
119 fi
aacfd6e1 120 $0 stop
121 $0 start
797fe9d4 122 ;;
123 status)
124 echo "Configured Mount Points:"
125 getmounts
126 echo ""
127 echo "Active Mount Points:"
128 ps ax|grep "[0-9]:[0-9][0-9] /usr/sbin/automount " | (
129 while read pid tt stat time command; do echo $command; done
130 )
131 ;;
132 *)
133 echo "Usage: $0 {start|stop|restart|reload|status}"
134 exit 1
135esac
136
137exit 0
This page took 0.065815 seconds and 4 git commands to generate.