fi
build_config || return 1
- interface_triggers "check_interface_up" || return 1
+ interface_triggers "check_interface_up" "upsmon" || return 1
return 0
;;
*)
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
}
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
# 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
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
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
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
# 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
# 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