Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > media > main-updates-src > by-pkgid > 640abb48b52a90082778e852612f363c > files > 11

autofs-5.0.1-0.rc3.1.2mdv2007.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

#
# Location of the automount daemon and the init directory
#
NAME=autofs
BINARY=/usr/sbin/automount
LOCKFILE=/var/lock/subsys/$NAME

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

[ -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
    return $RETVAL
}

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
        return $RETVAL
}

function restart() {
	stop
	start
}

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

RETVAL=0

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		restart
		;;
	reload)
		reload
		;;
	status)
		status $BINARY
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|reload|status}"
		exit 1;
		;;
esac

exit $?