File autofs-suse-autofs_init.patch of Package autofs5

Index: autofs-5.0.2/samples/rc.autofs.in
===================================================================
--- autofs-5.0.2.orig/samples/rc.autofs.in
+++ autofs-5.0.2/samples/rc.autofs.in
@@ -2,116 +2,152 @@
 #
 # rc file for automount using a Sun-style "master map".
 #
-# On most distributions, this file should be called:
-# /etc/rc.d/init.d/autofs or /etc/init.d/autofs or /etc/rc.d/rc.autofs
-#
+
+### BEGIN INIT INFO
+# Provides:       autofs
+# Required-Start: $network $syslog $remote_fs
+# Should-Start:   $portmap ypbind keyserv ldap gssd
+# Required-Stop:
+# Should-Stop:	  
+# Default-Start:  3 5
+# Default-Stop:
+# Description:    Start the autofs daemon for automatic mounting of filesystems.
+### END INIT INFO
 
 #
 # Location of the automount daemon and the init directory
 #
-DAEMON=@@sbindir@@/automount
+DAEMON=/usr/sbin/automount
 prog=`basename $DAEMON`
 MODULE="autofs4"
-confdir=@@autofsconfdir@@
+confdir=/etc/sysconfig
 
-test -e $DAEMON || exit 0
+test -x $DAEMON || exit 5
 
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 export PATH
 
+. /etc/rc.status
+
 #
 # load customized configuation settings
 #
 if [ -r $confdir/autofs ]; then
-	. $confdir/autofs
+    . $confdir/autofs
 fi
 
 function start() {
-	echo -n "Starting $prog: "
-
 	# Make sure autofs4 module is loaded
-	if ! grep -q autofs /proc/filesystems
-	then
-		# Try load the autofs4 module fail if we can't
-		modprobe $MODULE >/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
+    if ! grep -q autofs /proc/filesystems; then
+	# Try load the autofs4 module fail if we can't
+	modprobe -q $MODULE >/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
+
+    if [ "$LOCAL_OPTIONS" ]; then
+        AUTOFS_OPTIONS="-O $LOCAL_OPTIONS $AUTOFS_OPTIONS"
+    fi
+    /sbin/startproc $DAEMON $AUTOFS_OPTIONS
 
-	$prog $OPTIONS 
-	RETVAL=$?
-	if [ $RETVAL -eq 0 ] ; then
-		echo "done."
-	else
-		echo "failed."
-	fi
-	return $RETVAL
+    return $?
 }
 
 function stop() {
-	echo -n $"Stopping $prog: "
-	count=0
-	while [ -n "`pidof $DAEMON`" -a $count -lt 15 ] ; do
-		killall -TERM $prog >& /dev/null
-		RETVAL=$?
-		[ $RETVAL = 0 -a -z "`pidof $DAEMON`" ] || sleep 3
-		count=`expr $count + 1`
+    declare -i count=0
+    case "$RUNLEVEL" in
+    0|6|s|S)
+	for sig in TERM KILL ; do
+	    while read type path fs rest ; do
+		case "$fs" in
+		autofs)
+		    /bin/fuser -k -$sig -m $path/* >/dev/null 2>&1
+		esac
+	    done < /proc/mounts
+	    [ $sig = TERM ] && sleep 2
 	done
-	if [ -n "`pidof $DAEMON`" ] ; then
-		echo "done."
-	else
-		echo "failed."
-	fi
-	return $RETVAL
-}
+	/sbin/killproc -USR2 $DAEMON
+    esac
+    while [ $count -lt 15 ] ; do
+	/sbin/killproc -t3 -TERM $DAEMON
+	RETVAL=$?
+	[ $RETVAL -eq 1 ] || break
+	: $((count++))
+    done
 
-function restart() {
-	stop
-	start
+    return $RETVAL
 }
 
-function reload() {
-	pid=`pidof $DAEMON`
-	if [ -z $pid ]; then
-		echo $"$prog not running"
-		RETVAL=1
-	else
-		kill -HUP $pid 2> /dev/null
-		echo $"Reloading maps"
-		RETVAL=0
-	fi
-	return $RETVAL
-}
 
 RETVAL=0
 
 case "$1" in
-	start)
-		start
-		;;
-	stop)
-		stop
-		;;
-	restart)
-		restart
-		;;
-	reload)
-		reload
-		;;
-	*)
-		echo $"Usage: $0 {start|stop|restart|reload}"
-		exit 1;
-		;;
-esac
+    start)
+	echo -n "Starting $prog "
+	# Check if already running
+	if ! /sbin/checkproc $DAEMON; then
+	    start
+	fi
 
-exit $?
+	rc_status -v
+	;;
+    stop)
+	echo -n "Shutting down $prog "
+	stop
 
+	rc_status -v
+	;;
+    try-restart|condrestart)
+	## Do a restart only if the service was active before.
+	## Note: try-restart is now part of LSB (as of 1.9).
+	## RH has a similar command named condrestart.
+	if test "$1" = "condrestart"; then
+	    echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
+	fi
+	$0 status
+	if test $? = 0; then
+	    $0 restart
+	else
+	    rc_reset	# Not running is not a failure.
+	fi
+	# Remember status and be quiet
+	rc_status
+	;;
+    restart)
+	$0 stop
+	$0 start
+
+	rc_status
+	;;
+    force-reload)
+	echo -n "Reload service $prog "
+	/sbin/killproc -HUP $DAEMON
+	rc_status -v
+
+	;;
+    reload)
+	echo -n "Reload service $prog "
+	/sbin/killproc -HUP $DAEMON
+	rc_status -v
+
+	;;
+    status)
+	echo -n "Checking for service $prog "
+	/sbin/checkproc $DAEMON
+	# NOTE: rc_status knows that we called this init script with
+	# "status" option and adapts its messages accordingly.
+	rc_status -v
+	;;
+    *)
+	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
+	exit 1
+	;;
+esac
+rc_exit
openSUSE Build Service is sponsored by