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.

51 lines
1.1 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 [ "$(printf "%04x" 0x"$pvendid")" = "$vendorid" ] && \
  14. [ "$(printf "%04x" 0x"$pprodid")" = "$productid" ]; then
  15. [ "$ACTION" = "add" ] && {
  16. /etc/init.d/nut-server start "$cfg"
  17. }
  18. [ "$ACTION" = "remove" ] && {
  19. /etc/init.d/nut-server stop "$cfg"
  20. }
  21. found=1
  22. elif [ "$nomatch" = "1" ]; then
  23. [ "$ACTION" = "add" ] && {
  24. /etc/init.d/nut-server start "$cfg"
  25. }
  26. [ "$ACTION" = "remove" ] && {
  27. /etc/init.d/nut-server stop "$cfg"
  28. }
  29. fi
  30. }
  31. perform_libhid_action() {
  32. local vendorid productid runas
  33. local pvendid pprodid found
  34. pvendid=${PRODUCT%/*}
  35. pvendid=${pvendid%/*}
  36. pprodid=${PRODUCT%/*}
  37. pprodid=${pprodid##*/}
  38. config_load nut_server
  39. config_foreach nut_driver_config driver 0
  40. [ "$found" != "1" ] && config_foreach nut_driver_config driver 1
  41. }
  42. [ -n "$PRODUCT" ] && case "$PRODUCT" in