From 19394a4f2846bc397691acfe63c52a649e636089 Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Fri, 5 May 2017 15:14:55 +0200 Subject: [PATCH] TT#15855 Fix shellcheck/bashism warnings for mediator init script Warnings: > possible bashism in source/debian/mediator.init ... (echo -n) replaced with log_daemon_msg as lsb is in use. > FULLPATH appears unused. Verify it or export it. Removed. > Double quote to prevent globbing and word splitting. quoted where it is necessary and possible, muted for $OPTIONS. > Use $(..) instead of deprecated `..` Done. Change-Id: I4cbaee5859ab6deb25aef8ebbd1e392bd418b486 --- debian/mediator.init | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/debian/mediator.init b/debian/mediator.init index 82541c9..83e1d00 100755 --- a/debian/mediator.init +++ b/debian/mediator.init @@ -16,15 +16,10 @@ NAME=mediator DESC="ACC mediator" RUN_MEDIATOR=no -case $(dirname $0) in - /*) FULLPATH=$(dirname $0);; - *) FULLPATH=$(pwd)/$(dirname $0);; -esac - -DAEMON=`which mediator` +DAEMON=/usr/bin/mediator DEFAULTS=/etc/default/mediator -test -f $DAEMON || exit 0 +test -f "$DAEMON" || exit 0 # Load startup options if available if [ -f $DEFAULTS ]; then @@ -87,15 +82,16 @@ case "$1" in fi set -e - echo -n "Starting $DESC: $NAME" - start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE \ - --exec $DAEMON -- $OPTIONS || echo -n " already running" - log_end_msg $? + log_daemon_msg "Starting $DESC: $NAME" + # shellcheck disable=SC2086 + start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" \ + --exec "$DAEMON" -- $OPTIONS || log_progress_msg " already running" + log_end_msg $? ;; stop) - echo -n "Stopping $DESC: $NAME" - start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \ - --exec $DAEMON + log_daemon_msg "Stopping $DESC: $NAME" + start-stop-daemon --oknodo --stop --quiet --pidfile "$PIDFILE" \ + --exec "$DAEMON" if [ "$?" -ne 0 ]; then return $? fi @@ -103,13 +99,13 @@ case "$1" in log_end_msg $? ;; 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 - rm -f $PIDFILE + rm -f "$PIDFILE" sleep 1 if [ -x "/usr/sbin/ngcp-check_active" ]; then @@ -126,8 +122,9 @@ case "$1" in esac fi set -e + # shellcheck disable=SC2086 start-stop-daemon --start --quiet --pidfile \ - $PIDFILE --exec $DAEMON -- $OPTIONS + "$PIDFILE" --exec "$DAEMON" -- $OPTIONS log_end_msg $? ;; status)