From 87641067ba3379f75d4811d2d9a53e39c5f47045 Mon Sep 17 00:00:00 2001 From: Antoine Millet Date: Mon, 27 Dec 2010 17:23:37 +0100 Subject: [PATCH] Fixed initscript. --- debian/init | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/debian/init b/debian/init index b8031b6..4714a18 100755 --- a/debian/init +++ b/debian/init @@ -26,6 +26,9 @@ GROUP=cc-server # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 +# Override the VERBOSE variable so we always have feedback messages +VERBOSE=yes + # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh @@ -37,10 +40,15 @@ GROUP=cc-server # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME -if [ "$ENABLED" = "false" ] ; then - echo "$DESC disabled, see /etc/default/$NAME" - exit 0 -fi +# Read and parse configuration variable file if it is present +[ -r /etc/default/$NAME ] && { + . /etc/default/$NAME + # Do not start if service is disabled + if [ "$ENABLED" != "true" ] ; then + echo "$DESC disabled, see /etc/default/$NAME" + exit 0 + fi +} # # Function that starts the daemon/service @@ -55,6 +63,18 @@ do_start() -- $DAEMON_OPTS || return 2 } +# +# Function that starts the daemon/service +# +do_start() +{ + start-stop-daemon --start --quiet --background --name $NAME \ + --exec $(readlink -f $(which python)) --test > /dev/null || return 2 + start-stop-daemon --start --quiet --background --make-pidfile \ + --pidfile $PIDFILE --chuid $USER:$GROUP --exec $DAEMON \ + -- $DAEMON_OPTS || return 1 +} + # # Function that stops the daemon/service # @@ -109,20 +129,20 @@ case "$1" in # If the "reload" option is implemented then remove the # 'force-reload' alias # - log_daemon_msg "Restarting $DESC" "$NAME" + [ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start + 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 1) [ "$VERBOSE" != no ] && log_end_msg 1 ;; # Old process is still running + *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop - log_end_msg 1 + [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; -- GitLab