You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

  1. #!/bin/sh
  2. nut_driver_config() {
  3. local cfg="$1"
  4. local nomatch="$2"
  5. config_get runas "$cfg" runas "nut"
  6. config_get vendorid "$cfg" vendorid
  7. config_get productid "$cfg" productid
  8. [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && {
  9. chmod 0660 /dev/"$DEVNAME"
  10. chown "${runas:-root}":"$(id -gn "${runas:-root}")" /dev/"$DEVNAME"
  11. }
  12. if [ "$nomatch" = "1" ]; then
  13. [ "$ACTION" = "add" ] && {
  14. /etc/init.d/nut-server start "$cfg"
  15. }
  16. elif [ "$(printf "%04x" 0x"$pvendid")" = "$vendorid" ] && \
  17. [ "$(printf "%04x" 0x"$pprodid")" = "$productid" ]; then
  18. [ "$ACTION" = "add" ] && {
  19. /etc/init.d/nut-server start "$cfg"
  20. }
  21. [ "$ACTION" = "remove" ] && {
  22. /etc/init.d/nut-server stop "$cfg"
  23. }
  24. found=1
  25. fi
  26. }
  27. perform_libhid_action() {
  28. . /lib/functions.sh
  29. local vendorid productid runas
  30. local pvendid pprodid found
  31. pvendid=${PRODUCT%/*}
  32. pvendid=${pvendid%/*}
  33. pprodid=${PRODUCT%/*}
  34. pprodid=${pprodid##*/}
  35. config_load nut_server
  36. config_foreach nut_driver_config driver 0
  37. [ "$found" != "1" ] && config_foreach nut_driver_config driver 1
  38. /etc/init.d/nut-server start upsd
  39. }
  40. [ -n "$PRODUCT" ] && case "$PRODUCT" in