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.

66 lines
1.3 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. 'keepalive:uinteger:5' \
  14. 'token:maxlength(32)'
  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 "$port" ] && {
  33. echo "port required" >&2
  34. return 1
  35. }
  36. procd_open_instance
  37. procd_set_param command $BIN -h $host -p $port -a -k $keepalive
  38. [ -n "$ifname" ] && procd_append_param command -i "$ifname"
  39. [ -n "$id" ] && procd_append_param command -I "$id"
  40. [ -n "$description" ] && procd_append_param command -d "$description"
  41. [ "$ssl" = "1" ] && procd_append_param command -s
  42. [ -n "$token" ] && procd_append_param command -t "$token"
  43. procd_set_param respawn
  44. procd_close_instance
  45. }
  46. start_service() {
  47. config_load rtty
  48. config_foreach validate_rtty_section rtty start_rtty
  49. }
  50. service_triggers() {
  51. procd_add_reload_trigger "rtty"
  52. procd_add_validation validate_rtty_section
  53. }