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.

65 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. USE_PROCD=1
  3. START=99
  4. BIN=/usr/sbin/rtty
  5. validate_rtty_section() {
  6. uci_load_validate rtty rtty "$1" "$2" \
  7. 'interface:uci("network", "@interface"):lan' \
  8. 'id:maxlength(63)' \
  9. 'description:maxlength(126)' \
  10. 'host:host' \
  11. 'port:port' \
  12. 'ssl:bool:0' \
  13. 'token:maxlength(32)' \
  14. 'verbose:bool:0'
  15. }
  16. start_rtty() {
  17. . /lib/functions/network.sh
  18. local ifname
  19. [ "$2" = 0 ] || {
  20. echo "validation failed" >&2
  21. return 1
  22. }
  23. [ -n "$interface" ] && network_get_device ifname "$interface"
  24. [ -z "$ifname" -a -z "$id" ] && {
  25. echo "You must specify an interface or ID" >&2
  26. return 1
  27. }
  28. [ -z "$host" ] && {
  29. echo "host required" >&2
  30. return 1
  31. }
  32. [ -z "$id" ] && {
  33. id=$(sed 's/://g' /sys/class/net/$ifname/address | tr 'a-z' 'A-Z')
  34. }
  35. procd_open_instance
  36. procd_set_param command $BIN -h $host -I "$id" -a
  37. [ -n "$port" ] && procd_append_param command -p "$port"
  38. [ -n "$description" ] && procd_append_param command -d "$description"
  39. [ "$ssl" = "1" ] && procd_append_param command -s
  40. [ -n "$token" ] && procd_append_param command -t "$token"
  41. [ "$verbose" = "1" ] && procd_append_param command -v
  42. procd_set_param respawn
  43. procd_close_instance
  44. }
  45. start_service() {
  46. config_load rtty
  47. config_foreach validate_rtty_section rtty start_rtty
  48. }
  49. service_triggers() {
  50. procd_add_reload_trigger "rtty"
  51. procd_add_validation validate_rtty_section
  52. }