[DRE-commits] [schleuder] 06/14: debian/schleuder-api-daemon.init: Rework SysV init script

Georg Faerber georg-alioth-guest at moszumanska.debian.org
Tue Jun 20 14:57:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

georg-alioth-guest pushed a commit to branch schleuder/3.1.0-3
in repository schleuder.

commit 527174650df970a6442f8fb8f99c2949b9490f3c
Author: Georg Faerber <georg at riseup.net>
Date:   Sun Jun 18 13:18:47 2017 +0200

    debian/schleuder-api-daemon.init: Rework SysV init script
    
    - Fix formatting and styling
    - Lintian: Add re{quired,commend} commands {status,reload,force-reload}
---
 debian/schleuder-api-daemon.init | 91 ++++++++++++++++++++++------------------
 1 file changed, 50 insertions(+), 41 deletions(-)

diff --git a/debian/schleuder-api-daemon.init b/debian/schleuder-api-daemon.init
index 8918bc2..e8fd323 100755
--- a/debian/schleuder-api-daemon.init
+++ b/debian/schleuder-api-daemon.init
@@ -2,8 +2,8 @@
 
 ### BEGIN INIT INFO
 # Provides:          schleuder-api-daemon
-# Required-Start:    $local_fs $network $syslog
-# Required-Stop:     $local_fs $network $syslog
+# Required-Start:    $local_fs $remote_fs $network $syslog
+# Required-Stop:     $local_fs $remote_fs $network $syslog
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: Schleuder API daemon
@@ -18,61 +18,70 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
 NAME=schleuder-api-daemon
 DAEMON=/usr/bin/schleuder-api-daemon
+DESC="Schleuder API daemon"
 PIDFILE=/var/run/$NAME.pid
 USER=schleuder
 GROUP=schleuder
 
 test -x $DAEMON || exit 5
 
-start() {
-  if [ -f /var/run/$NAME.pid ]; then
-        log_failure_msg "$NAME is running already, please stop it first"
+start_schleuder_api_daemon() {
+    if [ -f "$PIDFILE" ]; then
+        echo ""
+        log_failure_msg "$DESC is running already, please stop it first"
         exit 1
-  fi
-
-  if ! id $USER >/dev/null 2>&1; then
+    fi
+    
+    if ! id $USER >/dev/null 2>&1; then
         log_failure_msg "User \"$USER\" does not exist"
         exit 1
-  fi
-
-  if ! getent group $GROUP >/dev/null 2>&1; then
+    fi
+    
+    if ! getent group $GROUP >/dev/null 2>&1; then
         log_failure_msg "Group \"$GROUP\" does not exist"
         exit 1
-  fi
-
-  log_daemon_msg "Starting $NAME" "$DAEMON"
-  start-stop-daemon --chuid "$USER":"$GROUP" --pidfile $PIDFILE --make-pidfile --background --exec $DAEMON --start
-  log_end_msg $?
+    fi
+    
+    start-stop-daemon --chuid "$USER":"$GROUP" --start --pidfile $PIDFILE  --make-pidfile --background --startas $DAEMON -- $NAME
 }
 
-stop() {
-  if ! [ -f /var/run/$NAME.pid ]; then
-        log_failure_msg "$NAME isn't running currently, nothing to do"
-        exit 1
-  fi
-
-  log_daemon_msg "Stopping $NAME" "$DAEMON"
-  start-stop-daemon --oknodo --pidfile $PIDFILE --stop --retry 10
-  log_end_msg $?
-  rm $PIDFILE
+stop_schleuder_api_daemon() {
+    if [ -f "$PIDFILE" ]; then
+        start-stop-daemon --stop --retry TERM/10/KILL/5 --pidfile $PIDFILE --quiet --oknodo --pidfile "$PIDFILE"
+        rm -f $PIDFILE
+    fi
 }
 
-restart() {
-  stop
-  start
+status_schleuder_api_daemon() {
+    if [ ! -e $PIDFILE ]; then
+        status_of_proc "${DAEMON}" "${DESC}"
+    else
+        status_of_proc -p "${PIDFILE}" "${DAEMON}" "${DESC}"
+    fi
 }
 
 case "$1" in
-  start)
-    start
-    ;;
-  stop)
-    stop
-    ;;
-  restart)
-    restart
-    ;;
-  *)
-    log_success_msg "Usage: $0 {start|stop|restart}"
-    exit 1
+    start)
+        log_begin_msg "Starting $DESC"
+        start_schleuder_api_daemon
+        log_end_msg $?
+        ;;
+    stop)
+        log_begin_msg "Stopping $DESC"
+        stop_schleuder_api_daemon
+        log_end_msg $?
+        ;;
+    status)
+        status_schleuder_api_daemon
+        ;;
+    restart|reload|force-reload)
+        log_begin_msg "Restarting $DESC"
+        stop_schleuder_api_daemon
+        start_schleuder_api_daemon
+        log_end_msg $?
+        ;;
+    *)
+        echo "Usage: $0 {start|stop|status|restart|reload|force-reload}"
+        exit 1
+        ;;
 esac

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/schleuder.git



More information about the Pkg-ruby-extras-commits mailing list