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.

58 lines
1.3 KiB

  1. #!/bin/sh /etc/rc.common
  2. . /lib/functions/network.sh
  3. USE_PROCD=1
  4. START=99
  5. BIN=/usr/sbin/rtty
  6. start_rtty() {
  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. [ $? -eq 1 ] && {
  17. echo "validation failed" >&2
  18. return 1
  19. }
  20. [ -n "$interface" ] && network_get_device ifname "$interface"
  21. [ -z "$ifname" -a -z "$id" ] && {
  22. echo "You must specify an interface or ID" >&2
  23. return 1
  24. }
  25. [ -z "$host" ] && {
  26. echo "host required" >&2
  27. return 1
  28. }
  29. [ -z "$port" ] && {
  30. echo "port required" >&2
  31. return 1
  32. }
  33. procd_open_instance
  34. procd_set_param command $BIN -h $host -p $port -a
  35. [ -n "$ifname" ] && procd_append_param command -i "$ifname"
  36. [ -n "$id" ] && procd_append_param command -I "$id"
  37. [ -n "$description" ] && procd_append_param command -d "$description"
  38. [ "$ssl" = "1" ] && procd_append_param command -s
  39. procd_set_param respawn
  40. procd_close_instance
  41. }
  42. start_service() {
  43. config_load rtty
  44. config_foreach start_rtty rtty
  45. }