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.

59 lines
1.3 KiB

  1. #!/bin/sh /etc/rc.common
  2. USE_PROCD=1
  3. START=99
  4. BIN=/usr/sbin/rtty
  5. start_rtty() {
  6. . /lib/functions/network.sh
  7. local cfg="$1"
  8. local interface ifname id description host port ssl
  9. uci_validate_section rtty rtty "${1}" \
  10. 'interface:uci("network", "@interface"):lan' \
  11. 'id:maxlength(63)' \
  12. 'description:maxlength(126)' \
  13. 'host:host' \
  14. 'port:port' \
  15. 'ssl:bool:0' \
  16. 'keepalive:uinteger:5'
  17. [ $? -ne 0 ] && {
  18. echo "validation failed" >&2
  19. return 1
  20. }
  21. [ -n "$interface" ] && network_get_device ifname "$interface"
  22. [ -z "$ifname" -a -z "$id" ] && {
  23. echo "You must specify an interface or ID" >&2
  24. return 1
  25. }
  26. [ -z "$host" ] && {
  27. echo "host required" >&2
  28. return 1
  29. }
  30. [ -z "$port" ] && {
  31. echo "port required" >&2
  32. return 1
  33. }
  34. procd_open_instance
  35. procd_set_param command $BIN -h $host -p $port -a -k $keepalive
  36. [ -n "$ifname" ] && procd_append_param command -i "$ifname"
  37. [ -n "$id" ] && procd_append_param command -I "$id"
  38. [ -n "$description" ] && procd_append_param command -d "$description"
  39. [ "$ssl" = "1" ] && procd_append_param command -s
  40. procd_set_param respawn
  41. procd_close_instance
  42. }
  43. start_service() {
  44. config_load rtty
  45. config_foreach start_rtty rtty
  46. }