[package] add init and configuration files for sslh (#5500)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@16838 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
ba6137c78e
commit
9c18f5a90e
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=sslh
|
||||
PKG_VERSION:=1.6i
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://rutschle.net/tech/
|
||||
@ -35,7 +35,10 @@ endef
|
||||
define Package/sslh/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/sslh $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME)
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) files/$(PKG_NAME).config $(1)/etc/config/$(PKG_NAME)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,sslh))
|
||||
|
||||
|
43
net/sslh/files/sslh.config
Normal file
43
net/sslh/files/sslh.config
Normal file
@ -0,0 +1,43 @@
|
||||
package 'sslh'
|
||||
|
||||
config 'sslh' 'default'
|
||||
# disable or enable
|
||||
option 'enable' '1'
|
||||
# listen defaults to '0.0.0.0:443' (all interfaces)
|
||||
# -p <listenaddr>:<listenport>
|
||||
option 'listen' ''
|
||||
# ssh defaults to 'localhost:22'
|
||||
# -s <sshhost>:<sshport>
|
||||
option 'ssh' ''
|
||||
# ssl defaults to 'localhost:442'
|
||||
# -l <sslhost>:<sslport>
|
||||
option 'ssl' ''
|
||||
# timeout (for ssh, then ssl is assumed) defaults to 2
|
||||
# -t
|
||||
option 'timeout' ''
|
||||
# verbose defaults to off
|
||||
# -v
|
||||
option 'verbose' '0'
|
||||
package 'sslh'
|
||||
|
||||
config 'sslh' 'default'
|
||||
# disable or enable start of sslh
|
||||
option 'enable' '1'
|
||||
# listen defaults to '0.0.0.0:443' (all interfaces)
|
||||
# -p <listenaddr>:<listenport>
|
||||
option 'listen' ''
|
||||
# ssh defaults to 'localhost:22'
|
||||
# -s <sshhost>:<sshport>
|
||||
option 'ssh' ''
|
||||
# ssl defaults to 'localhost:442'
|
||||
# -l <sslhost>:<sslport>
|
||||
option 'ssl' ''
|
||||
# pid file defaults to /var/run/sslh.pid
|
||||
# -P pidfile
|
||||
option 'pidfile' ''
|
||||
# timeout (for ssh, then ssl is assumed) defaults to 2
|
||||
# -t
|
||||
option 'timeout' ''
|
||||
# verbose defaults to off
|
||||
# -v
|
||||
option 'verbose' '0'
|
129
net/sslh/files/sslh.init
Normal file
129
net/sslh/files/sslh.init
Normal file
@ -0,0 +1,129 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2009 OpenWrt.org
|
||||
|
||||
NAME=sslh
|
||||
PROG=/usr/sbin/sslh
|
||||
START=95
|
||||
PIDCOUNT=0
|
||||
|
||||
sslh_start()
|
||||
{
|
||||
local section="$1"
|
||||
|
||||
# check if section is enabled (default)
|
||||
local enabled
|
||||
config_get_bool enabled "${section}" enable 1
|
||||
[ ${enabled} -eq 0 ] && return 1
|
||||
|
||||
# increase pid file count to handle multiple instances correctly
|
||||
PIDCOUNT="$(( ${PIDCOUNT} + 1 ))"
|
||||
|
||||
# prepare parameters (initialise with pid file)
|
||||
local args="-P /var/run/${NAME}.${PIDCOUNT}.pid"
|
||||
local val
|
||||
# A) listen parameter
|
||||
config_get val "${section}" listen
|
||||
[ ! -z ${val} ] && append args "-p ${val}"
|
||||
# B) ssh parameter
|
||||
config_get val "${section}" ssh
|
||||
[ ! -z ${val} ] && append args "-s ${val}"
|
||||
# C) ssl parameter
|
||||
config_get val "${section}" ssl
|
||||
[ ! -z ${val} ] && append args "-l ${val}"
|
||||
# D) timeout (for ssh, then ssl is assumed)
|
||||
config_get val "${section}" timeout
|
||||
[ ! -z ${val} ] && append args "-t ${val}"
|
||||
# E) verbose parameter
|
||||
local verbosed
|
||||
config_get_bool verbosed "${section}" verbose 0
|
||||
[ ${verbosed} -ne 0 ] && append args "-v"
|
||||
|
||||
# execute program and return its exit code
|
||||
[ ${verbosed} -ne 0 ] && echo "${NAME}: section ${section} starting ${PROG} ${args}"
|
||||
${PROG} ${args}
|
||||
return $?
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
config_load "${NAME}"
|
||||
config_foreach sslh_start sslh
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
local pidfile
|
||||
local rc=0
|
||||
|
||||
# killing all known processes
|
||||
for pidfile in `ls /var/run/${NAME}.*.pid`
|
||||
do
|
||||
start-stop-daemon -K -s KILL -p "${pidfile}" -n "${NAME}"
|
||||
[ $? -ne 0 ] && rc=1
|
||||
rm -f "${pidfile}"
|
||||
done
|
||||
|
||||
# kill orphaned processes
|
||||
if [ ${rc} -ne 0 ]
|
||||
then
|
||||
echo "${NAME}: inconsistency in pid files killing all orphaned processes"
|
||||
for pid in `pidof sslh`
|
||||
do
|
||||
# check if correct program
|
||||
ps | grep ${pid} | grep ${PROG} >/dev/null
|
||||
[ $? -ne 0 ] && continue
|
||||
|
||||
# kill process
|
||||
echo "Killing ${pid}..."
|
||||
kill -s KILL ${pid}
|
||||
done
|
||||
fi
|
||||
}
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2009 OpenWrt.org
|
||||
|
||||
NAME="$(basename "${initscript}")"
|
||||
PROG=/usr/sbin/${NAME}
|
||||
START=95
|
||||
|
||||
start()
|
||||
{
|
||||
# load config into variables
|
||||
uci_load "${NAME}"
|
||||
|
||||
# check if enabled
|
||||
local enabled
|
||||
config_get_bool enabled 'default' 'enable' 0
|
||||
if [ ${enabled} -eq 0 ]
|
||||
then
|
||||
echo "${NAME} is not enabled"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# prepare parameters
|
||||
local ARGS=''
|
||||
# A) listen parameter
|
||||
[ ! -z ${CONFIG_default_listen} ] && ARGS="${ARGS} -p ${CONFIG_default_listen}"
|
||||
# B) ssh parameter
|
||||
[ ! -z ${CONFIG_default_ssh} ] && ARGS="${ARGS} -s ${CONFIG_default_ssh}"
|
||||
# C) ssl parameter
|
||||
[ ! -z ${CONFIG_default_ssl} ] && ARGS="${ARGS} -l ${CONFIG_default_ssl}"
|
||||
# D) pid file
|
||||
[ ! -z ${CONFIG_default_pidfile} ] && ARGS="${ARGS} -P ${CONFIG_default_pidfile}"
|
||||
# E) timeout (for ssh, then ssl is assumed)
|
||||
[ ! -z ${CONFIG_default_timeout} ] && ARGS="${ARGS} -t ${CONFIG_default_timeout}"
|
||||
# F) verbose parameter
|
||||
local verbosed
|
||||
config_get_bool verbosed 'default' 'verbose' 0
|
||||
[ ${verbosed} -ne 0 ] && ARGS="${ARGS} -v"
|
||||
|
||||
# execute command and return its exit code
|
||||
[ ${verbosed} -ne 0 ] && echo "Starting ${PROG} ${ARGS}"
|
||||
${PROG} ${ARGS}
|
||||
return $?
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
killall "${NAME}"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user