nut: Fix undetected UPS hardware
authorDaniel F. Dickinson <redacted>
Wed, 10 Oct 2018 01:43:33 +0000 (21:43 -0400)
committerDaniel F. Dickinson <redacted>
Mon, 19 Nov 2018 21:39:39 +0000 (16:39 -0500)
Leading zeroes left in ProductId results in some UPS hardware not being matched
by the hotplug script lead to bad permissions and driver not starting.

Closes: #6966
Signed-off-by: Daniel F. Dickinson <redacted>
net/nut/Makefile
net/nut/files/30-libhid-ups.head

index 6108e27056b058b2d615b2abce5f4e8333387ff2..199014b2fd54f18de73159c87e3a5aafd344547c 100644 (file)
@@ -85,7 +85,7 @@ define Package/nut-server/install
        $(CP) $(PKG_INSTALL_DIR)/etc/hotplug/usb/libhid.usermap $(PKG_BUILD_DIR)/30-libhid-ups.middle
        $(SED) '/^$$$$/d' \
                -e '/^#/d' \
-               -E -e 's:^[^ ][^ ]*  *0x0003  *0x0{0,3}([^ ][^ ]*)  *0x{0,3}*([^ ][^ ]*).*:\1/\2/* | \\:' \
+               -E -e 's:^[^ ][^ ]*  *0x0003  *0x0{0,3}([^ ][^ ]*)  *0x0{0,3}*([^ ][^ ]*).*:\1/\2/* | \\:' \
                $(PKG_BUILD_DIR)/30-libhid-ups.middle
        tail -n+2 $(PKG_BUILD_DIR)/30-libhid-ups.middle >>$(1)/etc/hotplug.d/usb/30-libhid-ups
        cat ./files/30-libhid-ups.tail >>$(1)/etc/hotplug.d/usb/30-libhid-ups
index efcbcf66bd6fb22672eff0a63929040a3910311c..a65094646c3a84240f18be93c436691e16ce987e 100755 (executable)
@@ -15,22 +15,23 @@ nut_driver_config() {
                chown ${runas:-root}:$(id -gn "${runas:-root}") /dev/"$DEVNAME"
        }
 
-       if [ "$(printf "%04x" 0x"$pvendid")" = "$vendorid" ] && \
+       if [ "$nomatch" = "1" ]; then
+               [ "$ACTION" = "add" ] && {
+                       /etc/init.d/nut-server start "$cfg"
+               }
+               [ "$ACTION" = "remove" ] && {
+                       /etc/init.d/nut-server stop "$cfg"
+               }
+       elif [ "$(printf "%04x" 0x"$pvendid")" = "$vendorid" ] && \
                [ "$(printf "%04x" 0x"$pprodid")" = "$productid" ]; then
                        [ "$ACTION" = "add" ] && {
                                /etc/init.d/nut-server start "$cfg"
+                               /etc/init.d/nut-server reload upsd
                        }
                        [ "$ACTION" = "remove" ] && {
                                /etc/init.d/nut-server stop "$cfg"
                        }
                        found=1
-       elif [ "$nomatch" = "1" ]; then
-               [ "$ACTION" = "add" ] && {
-                       /etc/init.d/nut-server start "$cfg"
-               }
-               [ "$ACTION" = "remove" ] && {
-                       /etc/init.d/nut-server stop "$cfg"
-               }
        fi
 }
 
git clone https://git.99rst.org/PROJECT