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.

44 lines
1.0 KiB

  1. #!/bin/sh
  2. . /lib/functions.sh
  3. [ "$SUBSYSTEM" = "tty" ] || exit 0
  4. add() {
  5. local cfg="$1"
  6. local product serial symlink usbif
  7. [ -c "/dev/$DEVICENAME" ] || return
  8. config_get product "$cfg" product
  9. config_get serial "$cfg" serial
  10. config_get symlink "$cfg" symlink
  11. config_get usbif "$cfg" usbif
  12. [ -z "$product" -a -z "$serial" -a -z "$usbif" ] && return
  13. . "/sys/$DEVPATH/device/../uevent"
  14. SERIAL="$(cat /sys/$DEVPATH/device/../../serial)" 2>/dev/null
  15. USBIF="$(echo $DEVPATH | awk -F/ 'BEGIN {i=3}; /ACM/ {i=2}; END {print $(NF-i)}')"
  16. [ -n "$product" -a "$product" != "$PRODUCT" ] && return
  17. [ -n "$serial" -a "$serial" != "$SERIAL" ] && return
  18. [ -n "$usbif" -a "$usbif" != "$USBIF" ] && return
  19. chgrp domoticz "/dev/$DEVICENAME"
  20. chmod g+rw "/dev/$DEVICENAME"
  21. [ -n "$symlink" ] && ln -sf "/dev/$DEVICENAME" "/dev/$symlink"
  22. }
  23. remove() {
  24. local cfg="$1"
  25. local symlink
  26. config_get symlink "$cfg" symlink
  27. [ "/dev/$DEVICENAME" = "$(readlink /dev/$symlink)" ] && rm "/dev/$symlink"
  28. }
  29. config_load "domoticz"
  30. config_foreach "$ACTION" device