mirror of
https://github.com/openwrt/packages.git
synced 2026-10-12 08:07:24 +04:00
nut: improve hotplug behaviour for remove
Short-circuit not applicable portions of hotplug script on remove, and make sure we ignore events with incomplete information (no DEVNAME or no ACTION). Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
This commit is contained in:
1 parent
05f56830e9
commit
cf415f3e64
1 file changed
+10
-1
@@ -208,7 +208,7 @@ nut_driver_config() {
|
||||
# for this round
|
||||
# Initscript should have its own logging
|
||||
if ! start_stop_driver "$ups" "/dev/$DEVNAME"; then
|
||||
log_error "Error starting matched driver instance (UPS) in nut_driver_config" libhid-ups nut-usb-hotplug
|
||||
log_error "Failed to start/stop matched driver instance (UPS) in nut_driver_config" libhid-ups nut-usb-hotplug
|
||||
nd_driver_config_error=true
|
||||
return 0
|
||||
fi
|
||||
@@ -227,6 +227,9 @@ perform_libhid_action() {
|
||||
local nd_driver_config_error=false
|
||||
local pvendid pprodid
|
||||
|
||||
[ -n "$DEVNAME" ] || return 0
|
||||
[ -n "$ACTION" ] || return 0
|
||||
|
||||
# Only find statepath and runas once per event
|
||||
# defines STATEPATH
|
||||
find_statepath "upsd" "nut_server" || {
|
||||
@@ -268,6 +271,12 @@ perform_libhid_action() {
|
||||
config_foreach nut_driver_config driver yes
|
||||
|
||||
[ "$nd_driver_config_error" = "false" ] || return 1
|
||||
|
||||
# Only do a second search that does not need to match a known device
|
||||
# when ACTION is "add". We don't want to stop all UPSes on the removal
|
||||
# of only one.
|
||||
[ "$ACTION" = "add" ] || return 0
|
||||
|
||||
# Only if we cannot find a matching UPS (driver instance) configuration
|
||||
# do we try again, this time restarting all UPS (driver) instances
|
||||
# This is for the event the device matching configuration for NUT does
|
||||
|
||||
Reference in new issue
Block a user