Bug#920847: init-d-script: add do_restart_prepare and do_reload_prepare handlers
Mathieu Mirmont
mat at parad0x.org
Tue Jan 29 19:44:58 GMT 2019
Package: sysvinit
Version: 2.93-3
Severity: normal
Tags: patch
Dear Maintainer,
My package uses init-d-script and relies on defining a custom
"do_start_prepare" function to prevent starting the daemon if a
specific file exists.
While this works fine, it fails when the init.d script is invoked with
"restart" or "reload". In this case the "do_start_prepare" function is
not called. There doesn't seem to be a similar mechanism for "restart"
and "reload". This makes my init.d script significantly more
complicated to implement (cleanly).
Please consider the attached patch.
Cheers,
Mat.
-- System Information:
Debian Release: buster/sid
APT prefers testing
APT policy: (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.19.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=UTF-8) (ignored: LC_ALL set to C.UTF-8), LANGUAGE=C (charmap=UTF-8) (ignored: LC_ALL set to C.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: runit (via /run/runit.stopit)
*** /tmp/init-d-script.patch
diff -urN a/init-d-script b/init-d-script
--- a/init-d-script 2019-01-05 12:21:53.000000000 +0100
+++ b/init-d-script 2019-01-29 20:39:37.896029340 +0100
@@ -124,6 +124,9 @@
}
do_restart() {
+ if is_call_implemented do_restart_prepare ; then
+ call do_restart_prepare
+ fi
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
call do_stop_cmd
call do_start_cmd
@@ -131,6 +134,9 @@
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
+ if is_call_implemented do_restart_cleanup ; then
+ call do_restart_cleanup
+ fi
}
do_force_reload() {
@@ -144,10 +150,16 @@
# Enable this using
# alias do_reload=do_reload_sigusr1
do_reload_sigusr1() {
+ if is_call_implemented do_reload_prepare ; then
+ call do_reload_prepare
+ fi
log_daemon_msg "Reloading $DESC configuration files" "$NAME"
start-stop-daemon --oknodo --stop --signal 1 --quiet \
--pidfile "$PIDFILE" --exec "$DAEMON"
log_end_msg $?
+ if is_call_implemented do_reload_cleanup ; then
+ call do_reload_cleanup
+ fi
}
do_status() {
More information about the Debian-init-diversity
mailing list