mirror of
https://github.com/openwrt/packages.git
synced 2026-10-13 20:57:37 +04:00
nut: fix matching hotplugged device
The match against known device was badly formatted, and was not being used as a result. Fix that. Also, completely ignore events which are incomplete for our purposes (that is, which are missing ACTION or DEVNAME). Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
This commit is contained in:
1 parent
ca828ffc4f
commit
9ce5146f9f
2 files changed
+16
-11
No files matched your search
@@ -228,9 +228,6 @@ 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" || {
|
||||
@@ -313,24 +310,28 @@ perform_libhid_action() {
|
||||
# return) and shellcheck will complain if we do.
|
||||
}
|
||||
|
||||
# Ignore incomplete (for our purposes) events
|
||||
[ -n "$DEVNAME" ] || exit 0
|
||||
[ -n "$ACTION" ] || exit 0
|
||||
|
||||
# PRODUCT comes from the calling hotplug event, and
|
||||
# is of the form vendorid/productid/other
|
||||
|
||||
# This is an incomplete script which gets filled by libhid-ups.parsed-usermap.
|
||||
|
||||
# The result is cases of the form
|
||||
# "vendorid/productid/other" ) | \
|
||||
# to be matched against the PRODUCT from the calling hotplug event
|
||||
# The empty string matches when PRODUCT is empty, but does not match
|
||||
# when PRODUCT is neither empty nor one of the case targets, above
|
||||
|
||||
# This confuses shellcheck and reviewers, hence the disables below.
|
||||
# shellcheck disable=SC1073,SC1072
|
||||
case "$PRODUCT" in
|
||||
### insert libhid-ups.parsed-usermap content here ###
|
||||
# The result is cases of the form
|
||||
# "vendorid/productid/other" ) | \
|
||||
# to be matched against the PRODUCT from the calling hotplug event
|
||||
# and does NOT use ';;' (so falls through to code below).
|
||||
# The empty string matches when PRODUCT is empty, but does not match
|
||||
# when PRODUCT is neither empty nor one of the case targets, above
|
||||
|
||||
"")
|
||||
# Skip hotplug actions if NUT hotplug is disabled
|
||||
# Uses NUT_DISABLE_HOTPLUG_PATH, defined in nut-service.sh and sourced
|
||||
# Uses NUT_DISABLE_HOTPLUG_PATH, defined in nut-service.sh and sourced
|
||||
# NUT_DISABLE_HOTPLUG_PATH is an external sentinel used to indicate NUT
|
||||
# hotplug is disabled.
|
||||
if ! allow_hotplug_restart; then
|
||||
|
||||
@@ -159,6 +159,10 @@ nut_on_hotplug_add() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Ignore incomplete (for our purposes) events
|
||||
[ -n "$DEVNAME" ] || exit 0
|
||||
[ -n "$ACTION" ] || exit 0
|
||||
|
||||
# Do not do any hotplug actions if hotplug is disabled. Not an error but log
|
||||
# for information
|
||||
if ! allow_hotplug_restart; then
|
||||
|
||||
Reference in new issue
Block a user