Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > 5c005eb18a3b9c1baa0bed57734cded5 > files > 32

autofs-5.0.2-7mdv2008.0.src.rpm

#!/bin/sh

# chkconfig: 345 60 72
# description: This startup script launches the automounter

### BEGIN INIT INFO
# Provides: autofs
# Should-Start: $network $portmap nfslock ldap
# Should-Stop: $network $portmap nfslock
# Default-Start: 345
# Short-Description: Automounts filesystems on demand
# Description: This startup script launches the automounter
### END INIT INFO

# Local variables
NAME=autofs
BINARY=/usr/sbin/automount
LOCKFILE=/var/lock/subsys/$NAME

# Source function library.
. /etc/rc.d/init.d/functions

# Load service configuration
[ -f /etc/sysconfig/autofs ] && . /etc/sysconfig/autofs

function start() {
    if [ ! -f $LOCKFILE ]; then
	echo -n "Starting $NAME: "

	# Make sure autofs4 module is loaded
	if ! grep -q autofs /proc/filesystems; then
	    # Try load the autofs4 module fail if we can't
	    modprobe autofs4 >/dev/null 2>&1
	    if [ $? -eq 1 ]; then
		echo "Error: failed to load autofs4 module."
		return 1
	    fi
	elif ([ -f /proc/modules ] && lsmod) | grep -q autofs[^4]; then
	    # wrong autofs filesystem module loaded
	    echo
	    echo "Error: autofs kernel module is loaded, autofs4 required"
	    return 1
	fi

	daemon $BINARY $OPTIONS 
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch $LOCKFILE
	echo
    fi
}

function stop() {
    echo -n $"Stopping $NAME: "
    count=0
    while [ -f $LOCKFILE -a $count -lt 15 ]; do
	killproc $BINARY
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
	    rm -f $LOCKFILE
	else
	    count=$(($count+1))
	fi
    done
    echo
}

function restart() {
    stop
    start
}

function reload() {
    echo -n $"Reloading $NAME: "
    killproc $BINARY -HUP
    RETVAL=$?
    echo
}

RETVAL=0

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    restart)
	restart
	;;
    condrestart)
	if [ -f $LOCKFILE ]; then
	    restart
	fi
	;;
    reload)
	reload
	;;
    condreload)
	if [ -f $LOCKFILE ]; then
	    reload
	fi
	;;
    status)
	status $BINARY
	;;
    *)
	echo "Usage: $0 {start|stop|restart|reload|condrestart|condreload|status}"
	RETVAL=1
	;;
esac

exit $RETVAL