packages/net/sslh/files/sslh.init
nico 6bd8dc465e packages/sslh: use new service functions, with quirks to allow more than one instance to run simultaneously
git-svn-id: svn://svn.openwrt.org/openwrt/packages@29091 3c298f89-4303-0410-b956-a3cf2f4a3e73
2011-11-14 02:38:35 +00:00

55 lines
1.4 KiB
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2009-2011 OpenWrt.org
START=95
# XXX: pid-files are useless because sslh forks after creating them
SERVICE_USE_PID=
start_instance() {
local section="$1"
# check if section is enabled (default)
local enabled
config_get_bool enabled "${section}" 'enabled' '0'
[ ${enabled} -gt 0 ] || return 1
local args=""
local val
# A) listen parameter
config_get vals "${section}" listen
[ -n "${vals}" ] && for val in $vals; do append args "-p ${val}"; done
# B) ssh parameter
config_get val "${section}" ssh
[ -n "${val}" ] && append args "--ssh ${val}"
# C) ssl parameter
config_get val "${section}" ssl
[ -n "${val}" ] && append args "--ssl ${val}"
# D) openvpn parameter
config_get val "${section}" openvpn
[ -n "${val}" ] && append args "--openvpn ${val}"
# E) tinc parameter
config_get val "${section}" tinc
[ -n "${val}" ] && append args "--tinc ${val}"
# F) timeout (before a connection is considered to be SSH)
config_get val "${section}" timeout
[ -n "${val}" ] && append args "-t ${val}"
# G) verbose parameter
local verbosed
config_get_bool verbosed "${section}" verbose 0
[ "${verbosed}" -ne 0 ] && append args "-v"
# XXX: allow more that one instance to run simultaneously
SERVICE_MATCH_NAME=1 SERVICE_NAME="sslh-dummy-$$" \
service_start /usr/sbin/sslh ${args}
}
start() {
config_load 'sslh'
config_foreach start_instance 'sslh'
}
stop() {
service_stop /usr/sbin/sslh
}