nut: Fix nutmon issues with init
NUT's upsmon is rather peculiar in that it has a child process that runs as a regular user and a parent process that runs as root (in order to facilitate shutting down the device if needed). procd doesn't deal well with this and doing 'normal' procd stop / restart / etc results in the child process still hanging around but with not parent, which causes undesired behaviour. Therefore, add the use of 'upsmon -c stop' during process shutdown / restart in order to ensure that upsmon is actually fully stopped. Also fixes nut-monitor going into crashloop on network changes (due to trigger that restarted upsmon but failed due to orphan child from before restart). Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
This commit is contained in:
parent
bd061e154d
commit
867ea959a2
1 changed files with 6 additions and 9 deletions
|
@ -148,7 +148,6 @@ nut_upsmon_add() {
|
||||||
}
|
}
|
||||||
|
|
||||||
build_config() {
|
build_config() {
|
||||||
local runas=nutmon
|
|
||||||
mkdir -m 0750 -p "$(dirname "$UPSMON_C")"
|
mkdir -m 0750 -p "$(dirname "$UPSMON_C")"
|
||||||
|
|
||||||
config_load nut_monitor
|
config_load nut_monitor
|
||||||
|
@ -193,6 +192,7 @@ interface_triggers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
|
local runas=nutmon
|
||||||
local havemon havems
|
local havemon havems
|
||||||
build_config
|
build_config
|
||||||
|
|
||||||
|
@ -210,16 +210,9 @@ start_service() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
|
||||||
trap '' TERM
|
|
||||||
stop "$@"
|
|
||||||
sleep 2
|
|
||||||
trap - TERM
|
|
||||||
start "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
reload_service() {
|
reload_service() {
|
||||||
if pgrep upsmon >/dev/null 2>/dev/null; then
|
if pgrep upsmon >/dev/null 2>/dev/null; then
|
||||||
|
local runas=nutmon
|
||||||
build_config
|
build_config
|
||||||
/usr/sbin/upsmon -c reload
|
/usr/sbin/upsmon -c reload
|
||||||
else
|
else
|
||||||
|
@ -227,6 +220,10 @@ reload_service() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop_service() {
|
||||||
|
upsmon -c stop
|
||||||
|
}
|
||||||
|
|
||||||
service_triggers() {
|
service_triggers() {
|
||||||
config_load nut_monitor
|
config_load nut_monitor
|
||||||
interface_triggers "add_trigger"
|
interface_triggers "add_trigger"
|
||||||
|
|
Loading…
Reference in a new issue