From: Arthur Skowronek Date: Wed, 30 Jan 2019 13:58:47 +0000 (+0100) Subject: base-files: add service_stopped as a post stop hook X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=fc23bcdaa2f011ef47e2f6c6c1babad6fbdc3e7d;p=openwrt%2Fstaging%2Fjow.git base-files: add service_stopped as a post stop hook Purpose of these changes is to introduce a hook for post service shutdown in a similar fashion to the existing hook service_started. I found it to be useful to specify a hook that is called once the service has been stopped and not before the service is stopped like the stop_service hook does. The concrete use case I have for this is that I'm running a binary that takes over the hardware watchdog timer. Said binary unfortunately can not use ubus directly to tell procd to hand over the watchdog timer so this has to be done in the service file for the binary in question. In order to support a clean handover of the watchdog timer back to procd, the service init script has to dispatch the ubus invocation once the binary in question has been stopped. Signed-off-by: Arthur Skowronek Signed-off-by: Petr Štetiar [added commit message, use the same form as other hooks] --- diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common index d9773a0c5a..75dbeedf34 100755 --- a/package/base-files/files/etc/rc.common +++ b/package/base-files/files/etc/rc.common @@ -131,6 +131,9 @@ ${INIT_TRACE:+set -x} procd_lock stop_service "$@" procd_kill "$(basename ${basescript:-$initscript})" "$1" + if eval "type service_stopped" 2>/dev/null >/dev/null; then + service_stopped + fi } reload() {