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 <ags@digineo.de>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
[added commit message, use the same form as other hooks]
openwrt-19.07
Arthur Skowronek 2019-01-30 14:58:47 +01:00 committed by Petr Štetiar
parent 3b4c44aa8b
commit fc23bcdaa2
1 changed files with 3 additions and 0 deletions

View File

@ -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() {