]> git.99rst.org Git - openwrt-packages.git/commitdiff
nut: improve hotplug behaviour for remove
authorDaniel F. Dickinson <redacted>
Thu, 27 Aug 2026 10:12:21 +0000 (06:12 -0400)
committerJosef Schlehofer <redacted>
Thu, 10 Sep 2026 08:22:36 +0000 (10:22 +0200)
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 <redacted>
net/nut/files/libhid-ups.hotplug

index babbff17ac586fe2ca2b512e8a25d007d0c3e7b3..dc80df23007ceba419d3d3ede7ab25cd44778d21 100644 (file)
@@ -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
git clone https://git.99rst.org/PROJECT