1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2009 OpenWrt.org
13 # check if section is enabled (default)
15 config_get_bool enabled
"${section}" enable 1
16 [ "${enabled}" -eq 0 ] && return 1
18 # increase pid file count to handle multiple instances correctly
19 PIDCOUNT
="$(( ${PIDCOUNT} + 1 ))"
21 # prepare parameters (initialise with pid file)
22 local args
="-P /var/run/${NAME}.${PIDCOUNT}.pid"
25 config_get val
"${section}" listen
26 [ ! -z "${val}" ] && append args
"-p ${val}"
28 config_get val
"${section}" ssh
29 [ ! -z "${val}" ] && append args
"-s ${val}"
31 config_get val
"${section}" ssl
32 [ ! -z "${val}" ] && append args
"-l ${val}"
33 # D) timeout (for ssh, then ssl is assumed)
34 config_get val
"${section}" timeout
35 [ ! -z "${val}" ] && append args
"-t ${val}"
36 # E) verbose parameter
38 config_get_bool verbosed
"${section}" verbose
0
39 [ "${verbosed}" -ne 0 ] && append args
"-v"
41 # execute program and return its exit code
42 [ "${verbosed}" -ne 0 ] && echo "${NAME}: section ${section} starting ${PROG} ${args}"
50 config_foreach sslh_start sslh
58 # killing all known processes
59 for pidfile
in `ls /var/run/${NAME}.*.pid`
61 start-stop-daemon
-K -s KILL
-p "${pidfile}" -n "${NAME}"
66 # kill orphaned processes
69 echo "${NAME}: inconsistency in pid files killing all orphaned processes"
70 for pid
in `pidof sslh`
72 # check if correct program
73 ps |
grep "${pid}" |
grep "${PROG}" >/dev
/null
74 [ $?
-ne 0 ] && continue
77 echo "Killing ${pid}..."