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