Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 868628185b53e5dafbdd9634543e994e > files > 8

autofs-5.0.3-4mdv2008.1.x86_64.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 ypbind
# Should-Stop: $network $portmap nfslock ldap ypbind
# 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
	gprintf "Starting %s: " "$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
		gprintf "Error: failed to load autofs4 module.\n"
		return 1
	    fi
	elif ([ -f /proc/modules ] && lsmod) | grep -q autofs[^4]; then
	    # wrong autofs filesystem module loaded
	    echo
	    gprintf "Error: autofs kernel module is loaded, autofs4 required\n"
	    return 1
	fi

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

function stop() {
    gprintf "Stopping %s: " "$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() {
    gprintf "Reloading %s: " "$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
	;;
    *)
	gprintf "Usage: %s {start|stop|restart|reload|condrestart|condreload|status}\n" "$0"
	RETVAL=1
	;;
esac

exit $RETVAL