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.

34 lines
902 B

  1. #!/bin/sh
  2. nut_serial() {
  3. local cfg="$cfg"
  4. local runas enable_usb_serial port
  5. config_get_bool enable_usb_serial "$cfg" enable_usb_serial 0
  6. config_get port "$cfg" port
  7. config_get runas "$cfg" runas "nut"
  8. [ -z "$runas" ] && config_get runas upsd runas "nut"
  9. [ "$enable_usb_serial" -eq 1 ] && {
  10. # If port is specified only change tty's matching port
  11. if [ -n "$port" ] && [ "$port" != /dev/"$DEVNAME" ]; then
  12. return 0
  13. fi
  14. [ -n "$runas" ] && chgrp "$(id -gn "${runas}")" /dev/"$DEVNAME"
  15. chmod g+rw /dev/"$DEVNAME"
  16. }
  17. }
  18. nut_on_hotplug_add() {
  19. . "${IPKG_INSTROOT}"/lib/functions.sh
  20. config load nut_server
  21. config_foreach nut_serial driver
  22. }
  23. [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && {
  24. # On add of a serial port with name ttyUSB*
  25. [ -z "${DEVNAME%ttyUSB*}" ] && nut_on_hutplug_add
  26. # On add of a serial port with name ttyAMA*
  27. [ -z "${DEVNAME%ttyAMA*}" ] && nut_on_hutplug_add
  28. }