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.

55 lines
975 B

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2008-2014 OpenWrt.org
  3. START=99
  4. STOP=99
  5. USE_PROCD=1
  6. PROG=/usr/bin/socat
  7. NAME=socat
  8. validate_section_socat()
  9. {
  10. uci_load_validate socat socat "$1" "$2" \
  11. 'enable:bool:1' \
  12. 'SocatOptions:or(string, list(string))'
  13. }
  14. append_param_command()
  15. {
  16. procd_append_param command "$1"
  17. }
  18. socat_instance()
  19. {
  20. local is_list
  21. [ "$2" = 0 ] || {
  22. echo "validation failed"
  23. return 1
  24. }
  25. [ "$enable" = "0" ] && return 1
  26. procd_open_instance
  27. procd_set_param command "$PROG"
  28. config_get is_list "$1" SocatOptions_LENGTH
  29. if [ -z "$is_list" ]; then
  30. procd_append_param command $SocatOptions
  31. else
  32. config_list_foreach "$1" SocatOptions append_param_command
  33. fi
  34. procd_set_param stdout 1
  35. procd_set_param stderr 1
  36. procd_close_instance
  37. }
  38. start_service () {
  39. config_load "$NAME"
  40. config_foreach validate_section_socat socat socat_instance
  41. }
  42. service_triggers() {
  43. procd_add_reload_trigger "$NAME"
  44. procd_add_validation validate_section_socat
  45. }