mirror of
https://github.com/moparisthebest/sslh
synced 2024-11-23 17:42:22 -05:00
MINOR: init: Review RH/CentOS init script
This is an update of the init scripts originally written by Andre Krajnik. It is quite similar to other init scripts brought by common packages in RH/CentOS. This commit also introduces a pretty straight forward sysconfig file.
This commit is contained in:
parent
569c71f6b1
commit
5ae9ba184c
@ -1,56 +1,56 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# /etc/rc.d/init.d/sslh
|
# sslh Startup script for the SSL/SSH multiplexer
|
||||||
# sslh This shell script takes care of starting and stopping
|
|
||||||
# sslh - a daemon switching incoming connection between SSH and SSL/HTTPS servers
|
|
||||||
#
|
#
|
||||||
# Author: Andre Krajnik akrajnik@gmail.com
|
# chkconfig: - 13 87
|
||||||
# 2010-03-20
|
# description: Sslh accepts connections on specified ports, and forwards
|
||||||
|
# them further based on tests performed on the first data
|
||||||
|
# packet sent by the remote client.
|
||||||
|
# processname: sslh
|
||||||
|
# config: /etc/sslh.cfg
|
||||||
|
# config: /etc/sysconfig/sslh
|
||||||
|
# pidfile: /var/run/sslh/sslh.pid
|
||||||
#
|
#
|
||||||
#
|
# Authors:
|
||||||
# chkconfig: 2345 13 87
|
# Andre Krajnik akrajnik@gmail.com - 2010-03-20
|
||||||
#
|
# Julien Thomas julthomas@free.fr - 2013-08-25
|
||||||
# description: sslh - a daemon switching incoming connection between SSH and SSL/HTTPS servers
|
|
||||||
|
|
||||||
# Source function library.
|
# Source function library.
|
||||||
. /etc/init.d/functions
|
. /etc/init.d/functions
|
||||||
|
|
||||||
# ./sslh -p 0.0.0.0:8443 -l 127.0.0.1:443 -s 127.0.0.1:22
|
|
||||||
|
|
||||||
SSLH="/usr/local/sbin/sslh"
|
|
||||||
PIDFILE="/var/run/sslh"
|
|
||||||
|
|
||||||
OPTIONS="--user nobody --pidfile $PIDFILE -p 0.0.0.0:8443 --ssl 127.0.0.1:443 --ssh 127.0.0.1:22"
|
|
||||||
|
|
||||||
if [ -f /etc/sysconfig/sslh ]; then
|
if [ -f /etc/sysconfig/sslh ]; then
|
||||||
. /etc/sysconfig/sslh
|
. /etc/sysconfig/sslh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
start() {
|
PROGNAME=sslh
|
||||||
echo -n "Starting SSL-SSH-Switch: "
|
SSLH=${SSLH:-/usr/sbin/sslh-select}
|
||||||
if [ -f $PIDFILE ]; then
|
SSLH_LANG=${SSLH_LANG:-C}
|
||||||
PID=`cat $PIDFILE`
|
CONFIG=${CONFIG:-/etc/sslh.cfg}
|
||||||
echo sslh already running: $PID
|
PIDFILE=${PIDFILE:-/var/run/sslh/sslh.pid}
|
||||||
exit 2;
|
LOCKFILE=${LOCKFILE:-/var/lock/subsys/sslh}
|
||||||
else
|
STOP_TIMEOUT=${STOP_TIMEOUT:-10}
|
||||||
daemon $SSLH $OPTIONS
|
RETVAL=0
|
||||||
RETVAL=$?
|
|
||||||
echo
|
|
||||||
[ $RETVAL -eq 0 ] && touch $PIDFILE
|
|
||||||
return $RETVAL
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
start() {
|
||||||
|
echo -n "Starting $PROGNAME: "
|
||||||
|
LANG=$SSLH_LANG daemon --pidfile="$PIDFILE" \
|
||||||
|
${SSLH_USER:+--user="${SSLH_USER}"} \
|
||||||
|
"$SSLH" ${CONFIG:+-F "$CONFIG"} "$OPTIONS"
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
[ $RETVAL = 0 ] && touch "$LOCKFILE"
|
||||||
|
return $RETVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
echo -n "Shutting down SSL-SSH-Switch: "
|
echo -n "Stopping $PROGNAME: "
|
||||||
echo
|
killproc -p "$PIDFILE" -d "$STOP_TIMEOUT" "$SSLH"
|
||||||
killproc sslh
|
RETVAL=$?
|
||||||
echo
|
echo
|
||||||
rm -f $PIDFILE
|
[ $RETVAL = 0 ] && rm -f "$LOCKFILE" "$PIDFILE"
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# See how we were called.
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
start
|
start
|
||||||
@ -59,18 +59,17 @@ case "$1" in
|
|||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
status sslh
|
status -p "$PIDFILE" "$SSLH"
|
||||||
|
RETVAL=$?
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
stop
|
stop
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: {start|stop|status|restart}"
|
echo "Usage: $PROGNAME {start|stop|status|restart}"
|
||||||
exit 1
|
RETVAL=2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
exit $?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exit $RETVAL
|
||||||
|
36
scripts/etc.sysconfig.sslh
Normal file
36
scripts/etc.sysconfig.sslh
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#
|
||||||
|
# The default processing model uses select
|
||||||
|
# A fork model is also available
|
||||||
|
#
|
||||||
|
#SSLH=/usr/sbin/sslh-select
|
||||||
|
|
||||||
|
#
|
||||||
|
# If transparent mode is enabled, the following
|
||||||
|
# is needed in order to run as sslh user
|
||||||
|
#
|
||||||
|
#SSLH_USER=sslh
|
||||||
|
#setcap cap_net_bind_service,cap_net_admin=+ep $SSLH
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configuration file for sslh
|
||||||
|
# Set empty to disable configuration file support
|
||||||
|
#
|
||||||
|
#CONFIG=/etc/sslh.cfg
|
||||||
|
|
||||||
|
#
|
||||||
|
# Extra option to pass on comand line
|
||||||
|
# Those can supersede configuration file settings
|
||||||
|
#
|
||||||
|
#OPTIONS=
|
||||||
|
|
||||||
|
#
|
||||||
|
# The sslh process is started by default with the C
|
||||||
|
# locale, it can be changed here
|
||||||
|
#
|
||||||
|
#SSLH_LANG=C
|
||||||
|
|
||||||
|
#
|
||||||
|
# If an alternate location is specified in configuration
|
||||||
|
# file, it needs to be reported here
|
||||||
|
#
|
||||||
|
#PIDFILE=/var/run/sslh/sslh.pid
|
Loading…
Reference in New Issue
Block a user