1
0

socat.init 619 B

123456789101112131415161718192021222324252627282930313233343536373839
  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_validate_section socat socat "${1}" \
  11. 'enable:bool:1' \
  12. 'SocatOptions:string'
  13. return $?
  14. }
  15. socat_instance()
  16. {
  17. local SocatOptions enable
  18. validate_section_socat "${1}" || {
  19. echo "validation failed"
  20. return 1
  21. }
  22. [ "${enable}" = "0" ] && return 1
  23. procd_open_instance
  24. procd_set_param command "$PROG"
  25. procd_append_param command ${SocatOptions}
  26. procd_close_instance
  27. }
  28. start_service () {
  29. config_load "${NAME}"
  30. config_foreach socat_instance socat
  31. }