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.

65 lines
1.8 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2009-2017 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. # I) sslh config file (cmd line args override file settings)
  40. config_get val "${section}" configfile
  41. [ -n "${val}" ] && append args "-F${val}"
  42. # Defaults were removed for --user and --pidfile options
  43. # in sslh 1.11; Define them here instead.
  44. append args "--user nobody"
  45. append args "--pidfile /var/run/sslh.pid"
  46. # XXX: allow more that one instance to run simultaneously
  47. SERVICE_MATCH_NAME=1 SERVICE_NAME="sslh-dummy-$$" \
  48. service_start /usr/sbin/sslh ${args}
  49. }
  50. start() {
  51. config_load 'sslh'
  52. config_foreach start_instance 'sslh'
  53. }
  54. stop() {
  55. service_stop /usr/sbin/sslh
  56. }