mirror of
https://github.com/openwrt/packages.git
synced 2025-01-31 04:51:44 +00:00
d7db15459f
Small but important tweaks to fix the operation of the nut initscripts and hotplug scripts. All hail shellcheck and proofreading and dogfooding. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
50 lines
1.1 KiB
Bash
Executable File
50 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
nut_driver_config() {
|
|
local cfg="$1"
|
|
local nomatch="$2"
|
|
|
|
config_get runas "$cfg" runas "nut"
|
|
config_get vendorid "$cfg" vendorid
|
|
config_get productid "$cfg" productid
|
|
|
|
[ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && {
|
|
chmod 0660 /dev/"$DEVNAME"
|
|
chown "${runas:-root}":"$(id -gn "${runas:-root}")" /dev/"$DEVNAME"
|
|
}
|
|
|
|
if [ "$nomatch" = "1" ]; then
|
|
[ "$ACTION" = "add" ] && {
|
|
/etc/init.d/nut-server start "$cfg"
|
|
}
|
|
elif [ "$(printf "%04x" 0x"$pvendid")" = "$vendorid" ] && \
|
|
[ "$(printf "%04x" 0x"$pprodid")" = "$productid" ]; then
|
|
[ "$ACTION" = "add" ] && {
|
|
/etc/init.d/nut-server start "$cfg"
|
|
}
|
|
[ "$ACTION" = "remove" ] && {
|
|
/etc/init.d/nut-server stop "$cfg"
|
|
}
|
|
found=1
|
|
fi
|
|
}
|
|
|
|
perform_libhid_action() {
|
|
. /lib/functions.sh
|
|
|
|
local vendorid productid runas
|
|
local pvendid pprodid found
|
|
|
|
pvendid=${PRODUCT%/*}
|
|
pvendid=${pvendid%/*}
|
|
pprodid=${PRODUCT%/*}
|
|
pprodid=${pprodid##*/}
|
|
|
|
config_load nut_server
|
|
config_foreach nut_driver_config driver 0
|
|
[ "$found" != "1" ] && config_foreach nut_driver_config driver 1
|
|
/etc/init.d/nut-server start upsd
|
|
}
|
|
|
|
[ -n "$PRODUCT" ] && case "$PRODUCT" in
|