#! /bin/sh /usr/share/dpatch/dpatch-run
## 10lsb_initscript.dpatch by  <hesso@pool.math.tu-berlin.de>
##
## DP: Add an LSB header to the init script, add the mandatory
## DP: force-reload option and use start-stop-daemon instead of
## DP: invoking the binary manually.

@DPATCH@
--- autofs5-5.0.4.orig/samples/rc.autofs.in	2009-03-11 21:21:51.517895474 +0100
+++ autofs5-5.0.4/samples/rc.autofs.in	2009-03-11 21:30:02.804892695 +0100
@@ -7,11 +7,13 @@
 #
 #
 ### BEGIN INIT INFO
-# Provides: $autofs
-# Required-Start: $network $ypbind
-# Required-Stop: $network $ypbind
-# Default-Start: 3 4 5
-# Default-Stop: 0 1 2 6
+# Provides: autofs
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start: ypbind nslcd
+# Should-Stop: ypbind nslcd
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
 # Short-Description: Automounts filesystems on demand
 # Description: Automounts filesystems on demand
 ### END INIT INFO
@@ -75,28 +82,29 @@
 		fi
 	fi
 
-	$prog $OPTIONS 
+	start-stop-daemon --start --exec $DAEMON --oknodo -- $OPTIONS 
 	RETVAL=$?
 	if [ $RETVAL -eq 0 ] ; then
 		echo "done."
 	else
-		echo "failed."
+		echo "no valid automount entries defined."
 	fi
-	return $RETVAL
+	return 0
 }
 
 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
+		start-stop-daemon --stop --exec $DAEMON --oknodo
+		[ -z "`pidof $DAEMON`" ] || sleep 3
 		count=`expr $count + 1`
 	done
 	if [ -z "`pidof $DAEMON`" ] ; then
+		RETVAL=0
 		echo "done."
 	else
+		RETVAL=1
 		echo "failed."
 	fi
 	return $RETVAL
@@ -133,7 +141,7 @@
 	stop)
 		stop
 		;;
-	restart)
+	restart|force-reload)
 		restart
 		;;
 	forcerestart)
@@ -144,7 +152,7 @@
 		reload
 		;;
 	*)
-		echo $"Usage: $0 {start|forcestart|stop|restart|forcerestart|reload}"
+		echo $"Usage: $0 {start|forcestart|stop|restart|forcerestart|reload|force-reload}"
 		exit 1;
 		;;
 esac
