[PATCH 8/9] init-d-script: fix try-restart output and more verbosity
Trek
trek00 at inbox.ru
Fri Aug 28 07:21:58 BST 2020
On try-restart action, the fancy output is messed up by the
do_status and do_restart functions: log_use_fancy_output sets
FANCYTTY to 0 when redirected, but in subsequent calls it never
sets again FANCYTTY to 1. So call them in a subshell and redirect
stdout to /dev/null. Errors on do_status are now displayed.
On start and stop actions, print a message if nothing was done.
---
debian/init-d-script | 28 ++++++++++++++++++----------
debian/init-d-script.5 | 7 ++++++-
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/debian/init-d-script b/debian/init-d-script
index 8f4f0268..48a0cb6e 100755
--- a/debian/init-d-script
+++ b/debian/init-d-script
@@ -44,7 +44,7 @@ call() {
#
do_start_cmd() {
- start-stop-daemon --start --quiet --oknodo \
+ start-stop-daemon --start --quiet \
${PIDFILE:+--pidfile "$PIDFILE"} \
${COMMAND_NAME:+--name "$COMMAND_NAME"} \
${DAEMON:+--exec "$DAEMON"} $START_ARGS -- $DAEMON_ARGS
@@ -57,7 +57,11 @@ do_start()
fi
log_daemon_msg "Starting $DESC" "$NAME"
call do_start_cmd
- retval=$(( $? > 1 ))
+ retval=$?
+ if [ "$retval" = 1 ] && [ no != "$VERBOSE" ] ; then
+ log_progress_msg "is already running"
+ fi
+ retval=$(( $retval > 1 ))
vlog_end_msg $retval
if is_call_implemented do_start_cleanup ; then
call do_start_cleanup
@@ -70,7 +74,7 @@ do_start()
#
do_stop_cmd() {
- start-stop-daemon --stop --quiet --oknodo \
+ start-stop-daemon --stop --quiet \
--retry=TERM/0/CONT/30/KILL/5 \
${PIDFILE:+--pidfile "$PIDFILE"} \
${COMMAND_NAME:+--name "$COMMAND_NAME"} \
@@ -100,7 +104,11 @@ do_stop()
fi
vlog_daemon_msg "Stopping $DESC" "$NAME"
call do_stop_cmd
- retval=$(( $? > 1 ))
+ retval=$?
+ if [ "$retval" = 1 ] && [ no != "$VERBOSE" ] ; then
+ log_progress_msg "is not running"
+ fi
+ retval=$(( $retval > 1 ))
vlog_end_msg $retval
if is_call_implemented do_stop_cleanup ; then
call do_stop_cleanup
@@ -251,14 +259,14 @@ case "$1" in
call do_restart
;;
try-restart)
- log_daemon_msg "Trying to restart $DESC" "$NAME"
- if call do_status > /dev/null 2>&1 ; then
- call do_restart
- log_end_msg $?
+ vlog_daemon_msg "Trying to restart $DESC" "$NAME"
+ if (call do_status) >/dev/null ; then
+ (call do_restart) >/dev/null
else
- log_progress_msg "is not running."
- log_end_msg 0
+ [ no != "$VERBOSE" ] && log_progress_msg "is not running"
+ true
fi
+ vlog_end_msg $?
;;
'')
call do_usage
diff --git a/debian/init-d-script.5 b/debian/init-d-script.5
index 1d8a47be..50d6bb97 100644
--- a/debian/init-d-script.5
+++ b/debian/init-d-script.5
@@ -43,8 +43,13 @@ and
should be defined instead.
.It Ev DAEMON_ARGS
Additional arguments, passed to daemon during start.
+.It Ev DESC
+Full name or short description of the daemon, printed on screen.
+If unset, this variable defaults to the
+.Dq Ev NAME
+value.
.It Ev NAME
-Additional environment variables are sources from
+Additional environment variables are sourced from
.Pa /etc/default/${NAME} .
If unset, this variable defaults to the basename of the
.Dq Ev DAEMON
--
2.20.1
More information about the Debian-init-diversity
mailing list