sslocal.init 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006-2012 OpenWrt.org
  3. # Copyright (C) 2014 Zhao, Gang <gang.zhao.42@gmail.com>
  4. START=99
  5. USE_PROCD=1
  6. PROG=/usr/bin/sslocal
  7. validate_section_sslocal() {
  8. uci_validate_section sslocal sslocal "${1}" \
  9. 'server_addr:host' \
  10. 'server_port:port' \
  11. 'local_addr:host' \
  12. 'local_port:port' \
  13. 'password:string' \
  14. 'method:string' \
  15. 'log_level:range(0,7):5'
  16. return $?
  17. }
  18. sslocal_instance() {
  19. local server_addr server_port local_addr local_port
  20. local password method log_level
  21. validate_section_sslocal "${1}" || {
  22. echo "validation failed"
  23. return 1
  24. }
  25. procd_open_instance
  26. procd_set_param command "$PROG"
  27. procd_append_param command -s "${server_addr}" -p "${server_port}"
  28. procd_append_param command -u "${local_addr}" -b "${local_port}"
  29. procd_append_param command -k "${password}" -m "${method}"
  30. procd_append_param command -l "${log_level}"
  31. procd_set_param respawn
  32. procd_close_instance
  33. }
  34. start_service() {
  35. config_load sslocal
  36. config_foreach sslocal_instance sslocal
  37. }
  38. service_triggers()
  39. {
  40. procd_add_reload_trigger "sslocal"
  41. procd_add_validation validate_section_sslocal
  42. }