sslh.init 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2009-2012 OpenWrt.org
  3. START=95
  4. # XXX: pid-files are useless because sslh forks after creating them
  5. SERVICE_USE_PID=
  6. start_instance() {
  7. local section="$1"
  8. # check if section is enabled (default)
  9. local enable
  10. config_get_bool enable "${section}" 'enable' '0'
  11. [ ${enable} -gt 0 ] || return 1
  12. local args=""
  13. local val
  14. # A) listen parameter
  15. config_get vals "${section}" listen
  16. [ -n "${vals}" ] && for val in $vals; do append args "-p${val}"; done
  17. # B) ssh parameter
  18. config_get val "${section}" ssh
  19. [ -n "${val}" ] && append args "--ssh ${val}"
  20. # C) ssl parameter
  21. config_get val "${section}" ssl
  22. [ -n "${val}" ] && append args "--ssl ${val}"
  23. # D) openvpn parameter
  24. config_get val "${section}" openvpn
  25. [ -n "${val}" ] && append args "--openvpn ${val}"
  26. # E) tinc parameter
  27. config_get val "${section}" tinc
  28. [ -n "${val}" ] && append args "--tinc ${val}"
  29. # F) xmpp parameter
  30. config_get val "${section}" xmpp
  31. [ -n "${val}" ] && append args "--xmpp ${val}"
  32. # G) timeout (before a connection is considered to be SSH)
  33. config_get val "${section}" timeout
  34. [ -n "${val}" ] && append args "-t ${val}"
  35. # H) verbose parameter
  36. local verbosed
  37. config_get_bool verbosed "${section}" verbose 0
  38. [ "${verbosed}" -ne 0 ] && append args "-v"
  39. # Defaults were removed for --user and --pidfile options
  40. # in sslh 1.11; Define them here instead.
  41. append args "--user nobody"
  42. append args "--pidfile /var/run/sslh.pid"
  43. # XXX: allow more that one instance to run simultaneously
  44. SERVICE_MATCH_NAME=1 SERVICE_NAME="sslh-dummy-$$" \
  45. service_start /usr/sbin/sslh ${args}
  46. }
  47. start() {
  48. config_load 'sslh'
  49. config_foreach start_instance 'sslh'
  50. }
  51. stop() {
  52. service_stop /usr/sbin/sslh
  53. }