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.

52 lines
1.2 KiB

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