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.

69 lines
1.5 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. 'insecure:bool:0' \
  14. 'token:maxlength(32)' \
  15. 'username:string' \
  16. 'verbose:bool:0'
  17. }
  18. start_rtty() {
  19. . /lib/functions/network.sh
  20. local ifname
  21. [ "$2" = 0 ] || {
  22. echo "validation failed" >&2
  23. return 1
  24. }
  25. [ -n "$interface" ] && network_get_device ifname "$interface"
  26. [ -z "$ifname" -a -z "$id" ] && {
  27. echo "You must specify an interface or ID" >&2
  28. return 1
  29. }
  30. [ -z "$host" ] && {
  31. echo "host required" >&2
  32. return 1
  33. }
  34. [ -z "$id" ] && {
  35. id=$(sed 's/://g' /sys/class/net/$ifname/address | tr 'a-z' 'A-Z')
  36. }
  37. procd_open_instance
  38. procd_set_param command $BIN -h $host -I "$id" -a
  39. [ -n "$port" ] && procd_append_param command -p "$port"
  40. [ -n "$description" ] && procd_append_param command -d "$description"
  41. [ "$ssl" = "1" ] && procd_append_param command -s
  42. [ "$insecure" = "1" ] && procd_append_param command -x
  43. [ -n "$token" ] && procd_append_param command -t "$token"
  44. [ -n "$username" ] && procd_append_param command -f "$username"
  45. [ "$verbose" = "1" ] && procd_append_param command -v
  46. procd_set_param respawn
  47. procd_close_instance
  48. }
  49. start_service() {
  50. config_load rtty
  51. config_foreach validate_rtty_section rtty start_rtty
  52. }
  53. service_triggers() {
  54. procd_add_reload_trigger "rtty"
  55. procd_add_validation validate_rtty_section
  56. }