From 9e38b8fa9429e0f5586a366824d42f95efd3acf5 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 30 Nov 2016 09:09:37 -0500 Subject: [PATCH] modernize debian init.d script to eliminate warnings Change-Id: I06a01c82a3f7547d939e5d41de4535f91a423f90 --- debian/ngcp-rtpengine-daemon.init | 35 +++++++++++++------------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/debian/ngcp-rtpengine-daemon.init b/debian/ngcp-rtpengine-daemon.init index 8ec60fec7..432a06082 100755 --- a/debian/ngcp-rtpengine-daemon.init +++ b/debian/ngcp-rtpengine-daemon.init @@ -16,22 +16,17 @@ NAME=ngcp-rtpengine-daemon DESC="RTP/media proxy" TABLE=0 -case $(dirname $0) in - /*) FULLPATH=$(dirname $0);; - *) FULLPATH=$(pwd)/$(dirname $0);; -esac - -DAEMON=`which rtpengine` +DAEMON=$(which rtpengine) DEFAULTS=/etc/default/${NAME} -test -f $DAEMON || exit 0 +test -f "$DAEMON" || exit 0 # Load startup options if available -if [ -f $DEFAULTS ]; then - . $DEFAULTS || true +if [ -f "$DEFAULTS" ]; then + . "$DEFAULTS" || true fi -if [ "$RUN_RTPENGINE" != "yes" -a "$RUN_MEDIAPROXY" != "yes" ]; then +if [ "$RUN_RTPENGINE" != "yes" ]; then echo "rtpengine not yet configured. Edit $DEFAULTS first." exit 0 fi @@ -137,7 +132,7 @@ case "$1" in ;; esac fi - echo -n "Starting $DESC: $NAME" + log_daemon_msg "Starting $DESC: $NAME" if [ "$TABLE" -ge 0 ] && [ "$VIRT" != "yes" ]; then set +e modprobe xt_RTPENGINE @@ -175,14 +170,14 @@ case "$1" in fi set -e fi - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --exec $DAEMON -- $OPTIONS || echo -n " already running" + start-stop-daemon --start --quiet --pidfile "$PIDFILE" \ + --exec "$DAEMON" -- $OPTIONS || log_progress_msg " already running" log_end_msg $? ;; stop) - echo -n "Stopping $DESC: $NAME" + log_daemon_msg "Stopping $DESC: $NAME" start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \ - --exec $DAEMON + --exec "$DAEMON" if [ "$?" -ne 0 ]; then return $? fi @@ -214,9 +209,9 @@ case "$1" in ;; restart|force-reload) - echo -n "Restarting $DESC: $NAME" + log_daemon_msg "Restarting $DESC: $NAME" start-stop-daemon --oknodo --stop --quiet --pidfile \ - $PIDFILE --exec $DAEMON + "$PIDFILE" --exec $DAEMON if [ "$?" -ne 0 ]; then return $? fi @@ -226,10 +221,10 @@ case "$1" in status=$? case "${status}" in 0|3) - echo "Active node or transition." + log_progress_msg "Active node or transition." ;; *) - echo "Ignored start action in inactive node ($status)" + log_progress_msg "Ignored start action in inactive node ($status)" exit 0 ;; esac @@ -273,7 +268,7 @@ case "$1" in set -e fi start-stop-daemon --start --quiet --pidfile \ - $PIDFILE --exec $DAEMON -- $OPTIONS + "$PIDFILE" --exec "$DAEMON" -- $OPTIONS log_end_msg $? ;; status)