mirror of
https://github.com/openwrt/packages.git
synced 2026-10-13 20:57:37 +04:00
nut: do not trigger on interface activity by default
The defaults were triggiering on any activity on the network, which caused excessive restarts. So default to no interface trigger, with 'all' (or specific interfaces) as an option. See https://github.com/openwrt/packages/pull/29607#discussion_r3463553192 Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
This commit is contained in:
1 parent
ce009de85f
commit
0bd44d9b9d
5 files changed
+30
-20
No files matched your search
@@ -92,7 +92,7 @@ service_preconditions() {
|
||||
fi
|
||||
|
||||
build_config || return 1
|
||||
interface_triggers "check_interface_up" || return 1
|
||||
interface_triggers "check_interface_up" "upsmon" || return 1
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
@@ -211,6 +211,8 @@ service_triggers() {
|
||||
|
||||
config_get interface_reload_delay upsmon interface_reload_delay $DEFAULT_PROCD_INTERFACE_RELOAD_DELAY
|
||||
|
||||
# We do not pass an instance name as the nut-monitor initscript does not need
|
||||
# an additional instance argument
|
||||
interface_triggers "add_trigger" "upsmon" "$interface_reload_delay" "nut-monitor" || {
|
||||
log_error_exit "Failed to add interface triggers" nut-monitor nut-monitor
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ service_preconditions() {
|
||||
|
||||
case $ret in
|
||||
0)
|
||||
interface_triggers "check_interface_up" || should_start_srv=false
|
||||
interface_triggers "check_interface_up" "upsd" || should_start_srv=false
|
||||
;;
|
||||
*)
|
||||
should_start_srv=false
|
||||
@@ -269,7 +269,7 @@ service_preconditions() {
|
||||
|
||||
case $ret in
|
||||
0 | 2)
|
||||
interface_triggers "check_interface_up" || should_stop_srv=true
|
||||
interface_triggers "check_interface_up" "upsd" || should_stop_srv=true
|
||||
;;
|
||||
*)
|
||||
should_stop_srv=true
|
||||
|
||||
@@ -278,7 +278,9 @@ interface_triggers() {
|
||||
local section="$2"
|
||||
local interface_reload_delay="${3:-$DEFAULT_PROCD_INTERFACE_RELOAD_DELAY}"
|
||||
local initscript="$4"
|
||||
local daemon="$5"
|
||||
if [ $# -ge 4 ]; then
|
||||
shift 4
|
||||
fi
|
||||
local interfaces interface
|
||||
local have_up_interface
|
||||
local trigger_failed
|
||||
@@ -289,7 +291,7 @@ interface_triggers() {
|
||||
# We do not need to log or otherwise 'notice' other actions
|
||||
case "$action" in
|
||||
add_trigger)
|
||||
if [ -n "$interfaces" ]; then
|
||||
if [ -n "$interfaces" ] && [ "$interfaces" != "all" ]; then
|
||||
set -f
|
||||
trigger_failed="false"
|
||||
# interfaces is deliberately unquoted so we get word-splitting for
|
||||
@@ -297,21 +299,23 @@ interface_triggers() {
|
||||
for interface in $interfaces; do
|
||||
# We use the variadic third and fourth parameters of procd_add_interface_trigger to
|
||||
# restart instead of reload on interface up/down events. Additionally the variadic
|
||||
# fourth and fifth parameters of procd_add_interface_trigger are passed through to
|
||||
# the <script>, so the trigger action becomes e.g. /etc/init.d/<script> restart "$daemon".
|
||||
procd_add_interface_trigger "interface.*.up" "$interface" "/etc/init.d/$initscript" "restart" "$daemon" || trigger_failed="true"
|
||||
# fifth and parameters of procd_add_interface_trigger are passed through to
|
||||
# the <script>, so the trigger action becomes e.g. /etc/init.d/<script> restart <variadic_vars>.
|
||||
procd_add_interface_trigger "interface.*.up" "$interface" "/etc/init.d/$initscript" "restart" "$@" || trigger_failed="true"
|
||||
done
|
||||
set +f
|
||||
if [ "$trigger_failed" = "true" ]; then
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
elif [ "$interfaces" = "all" ]; then
|
||||
# Add a restart trigger on any interface's up status changing
|
||||
procd_add_raw_trigger "interface.*.up" "$interface_reload_delay" "/etc/init.d/$initscript" "restart" || return 1
|
||||
procd_add_raw_trigger "interface.*.up" "$interface_reload_delay" "/etc/init.d/$initscript" "restart" "$@" || return 1
|
||||
else
|
||||
return 0 # don't react to interface status
|
||||
fi
|
||||
;;
|
||||
check_interface_up)
|
||||
if [ -n "$interfaces" ]; then
|
||||
if [ -n "$interfaces" ] && [ "$interfaces" != "all" ]; then
|
||||
set -f
|
||||
have_up_interface="false"
|
||||
for interface in $interfaces; do
|
||||
@@ -322,7 +326,7 @@ interface_triggers() {
|
||||
log_msg "None of the trigger interfaces are up." "nut-service.sh" "nut-service" "notice"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
elif [ "$interfaces" = "all" ]; then
|
||||
# Return true if any interface is up
|
||||
# -q for jsonfilter only suppress error output, not messages on
|
||||
# stdout, redirect to >/dev/null is needed to avoid all output
|
||||
@@ -331,6 +335,8 @@ interface_triggers() {
|
||||
fi
|
||||
log_msg "No interfaces are up." "nut-service.sh" "nut-service" "notice"
|
||||
return 1
|
||||
else
|
||||
return 0 # don't depend on interface status
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
# option debugmin 0
|
||||
# option defaultnotify SYSLOG
|
||||
# option interface_reload_delay 3000 # in milliseconds
|
||||
# option triggerlist all # not configured by default
|
||||
|
||||
#config monitor
|
||||
# option type primary
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
# permissions to access the UPS device(s)
|
||||
|
||||
# example USB UPS configuration
|
||||
# config driver 'upsname'
|
||||
# option driver usbhid-ups
|
||||
# option port auto
|
||||
# option productid 12ab # USB 4-digit hex productId
|
||||
# option vendorid 34cd # USB 4-digit hex vendorId
|
||||
#config driver 'upsname'
|
||||
# option driver usbhid-ups
|
||||
# option port auto
|
||||
# option productid 12ab # USB 4-digit hex productId
|
||||
# option vendorid 34cd # USB 4-digit hex vendorId
|
||||
|
||||
# Configuration for UPS connected to serial-USB
|
||||
# option enable_usb_serial 0
|
||||
# option enable_usb_serial 0
|
||||
|
||||
|
||||
#config user
|
||||
@@ -36,6 +36,7 @@
|
||||
# option statepath /var/run/nut
|
||||
# option maxconn 1024
|
||||
# option runas nut
|
||||
# option interface_reload_delay 3000 # in milliseconds
|
||||
# option interface_reload_delay 3000 # in milliseconds
|
||||
# NB: certificates only apply to SSL-enabled version
|
||||
# option certfile /usr/local/etc/upsd.pem
|
||||
# option certfile /usr/local/etc/upsd.pem
|
||||
# option triggerlist all # not configured by default
|
||||
Reference in new issue
Block a user