Bug#843419: init-d-script: please provide a way to not use the --name option of start-stop-daemon

Dmitry Bogatov KAction at debian.org
Wed Feb 27 03:01:40 GMT 2019

control: tags -1 +patch

[2019-02-24 13:24] wferi at niif.hu
> > Dmitry Bogatov <KAction at debian.org> writes:
> > Sorry, I do not understand. You, as init script writer, choose value of
> > argument to $NAME. Why can't you limit it to required length?
> [...]
> I imagine that having an optional COMM_NAME (pick any name) variable
> would solve this nicely, if it was used in preference to NAME for the
> --name option of start-stop-daemon if it was set, like

What about this patch? Would it satisfy your need? Can you please review
wording -- I am very bad at writing manpages.

From 4eaaa037824b708476bb677061e36b4c19cff089 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <KAction at debian.org>
Date: Mon, 25 Feb 2019 10:49:27 +0000
Subject: [PATCH] Add new parameter COMMAND_NAME to init-d-script

Introduce new parameter COMMAND_NAME that can be used in `init-d-script'
based initscripts. Value of that parameter is used as argument to --name
option in start-stop-daemon invocations. (Closes: #834419)
 debian/init-d-script   |  7 ++++---
 debian/init-d-script.5 | 14 ++++++++++----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/debian/init-d-script b/debian/init-d-script
index 131dbd65..b5ef04d5 100755
--- a/debian/init-d-script
+++ b/debian/init-d-script
@@ -50,11 +50,11 @@ call() {
 do_start_cmd() {
 	start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} \
 	    $START_ARGS \
-	    --startas $DAEMON --name $NAME --exec $DAEMON --test > /dev/null \
+	    --startas $DAEMON --name ${COMMAND_NAME} --exec $DAEMON --test > /dev/null \
 	    || return 1
 	start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} \
 	    $START_ARGS \
-	    --startas $DAEMON --name $NAME --exec $DAEMON -- $DAEMON_ARGS \
+	    --startas $DAEMON --name ${COMMAND_NAME} --exec $DAEMON -- $DAEMON_ARGS \
 	    || return 2
 	# Add code here, if necessary, that waits for the process to be ready
 	# to handle requests from services started subsequently which depend
@@ -89,7 +89,7 @@ do_start()
 do_stop_cmd() {
 	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
 	    $STOP_ARGS \
-	    ${PIDFILE:+--pidfile ${PIDFILE}} --name $NAME --exec $DAEMON
+	    ${PIDFILE:+--pidfile ${PIDFILE}} --name ${COMMAND_NAME} --exec $DAEMON
 	[ "$RETVAL" = 2 ] && return 2
 	# Wait for children to finish too if this is a daemon that forks
@@ -182,6 +182,7 @@ fi
 NAME=${NAME:=$(basename $DAEMON)}
 # Do not use pid file if $PIDFILE is 'none'.  Otherwise, generate from
 # $NAME or use the value provided by the init.d script.
diff --git a/debian/init-d-script.5 b/debian/init-d-script.5
index ee645c58..05a03f6b 100644
--- a/debian/init-d-script.5
+++ b/debian/init-d-script.5
@@ -44,12 +44,18 @@ DAEMON=/usr/sbin/atd
 In addition to the DAEMON setting, one can specify DESC, NAME,
-PIDFILE (`none' means no PID file), or implement override functions
-do_force_reload_override, do_reload_override, do_restart_override,
-do_start_override, do_start_cmd_override, do_start_prepare,
-do_start_cleanup do_status_override, do_stop_override,
+COMMAND_NAME, PIDFILE (`none' means no PID file), or implement
+override functions do_force_reload_override, do_reload_override,
+do_restart_override, do_start_override, do_start_cmd_override,
+do_start_prepare, do_start_cleanup do_status_override, do_stop_override,
 do_stop_prepare, do_stop_cleanup and do_stop_cmd_override.
+Argument to
+.I --name
+option of
+.B start-stop-daemon
+program is  COMMAND_NAME variable, if it is set, or NAME otherwise.
 If the daemon support reloading, implement the do_reload function to
 make the init.d script recognize the reload operation as well as use
 it for the force-reload operation.
        Note, that I send and fetch email in batch, once every 24 hours.
                 If matter is urgent, try https://t.me/kaction

More information about the Debian-init-diversity mailing list