From 9b82cff2ea29fcbe492e7c4eb81ad869e009ee6a Mon Sep 17 00:00:00 2001
From: Mathieu Parent <math.parent@gmail.com>
Date: Thu, 23 May 2013 16:24:00 +0200
Subject: [PATCH] Merge init skeleton from sysvinit

- Required-Start: $network $local_fs -> $local_fs $network $remote_fs $syslog
- Required-Stop: -> $local_fs $network $remote_fs $syslog
- Add: Do NOT "set -e"
- Remove comments for $DESC, $NAME, $DAEMON, $DAEMON_ARGS
- Quote $DAEMON to avoid syntax error when empty
- status_of_proc is requiring lsb-base (>= 3.2-14)
- Indentation fixes
---
 lib/debian/init.d.ex |   33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/lib/debian/init.d.ex b/lib/debian/init.d.ex
index b63dbef..5dcd3e3 100755
--- a/lib/debian/init.d.ex
+++ b/lib/debian/init.d.ex
@@ -1,8 +1,8 @@
 #!/bin/sh
 ### BEGIN INIT INFO
 # Provides:          #PACKAGE#
-# Required-Start:    $network $local_fs
-# Required-Stop:
+# Required-Start:    $local_fs $network $remote_fs $syslog
+# Required-Stop:     $local_fs $network $remote_fs $syslog
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: <Enter a short description of the software>
@@ -13,17 +13,19 @@
 
 # Author: #USERNAME# <#EMAIL#>
 
+# Do NOT "set -e"
+
 # PATH should only include /usr/* if it runs after the mountnfs.sh script
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
-DESC=#PACKAGE#             # Introduce a short description here
-NAME=#PACKAGE#             # Introduce the short server's name here
-DAEMON=/usr/sbin/#PACKAGE# # Introduce the server's location here
-DAEMON_ARGS=""             # Arguments to run the daemon with
+DESC="#PACKAGE#"
+NAME=#PACKAGE#
+DAEMON=/usr/sbin/#PACKAGE#
+DAEMON_ARGS=""
 PIDFILE=/var/run/$NAME.pid
 SCRIPTNAME=/etc/init.d/$NAME
 
 # Exit if the package is not installed
-[ -x $DAEMON ] || exit 0
+[ -x "$DAEMON" ] || exit 0
 
 # Read configuration variable file if it is present
 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
@@ -32,7 +34,8 @@ SCRIPTNAME=/etc/init.d/$NAME
 . /lib/init/vars.sh
 
 # Define LSB log_* functions.
-# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
 . /lib/lsb/init-functions
 
 #
@@ -104,13 +107,13 @@ do_reload() {
 
 case "$1" in
   start)
-    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
-    do_start
-    case "$?" in
+	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+	do_start
+	case "$?" in
 		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 	esac
-  ;;
+	;;
   stop)
 	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
 	do_stop
@@ -120,8 +123,8 @@ case "$1" in
 	esac
 	;;
   status)
-       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
-       ;;
+	status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+	;;
   #reload|force-reload)
 	#
 	# If do_reload() is not implemented then leave this commented out
@@ -148,7 +151,7 @@ case "$1" in
 		esac
 		;;
 	  *)
-	  	# Failed to stop
+		# Failed to stop
 		log_end_msg 1
 		;;
 	esac
-- 
1.7.10.4

