2013-07-10 17:11:40 -04:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# /etc/rc.d/init.d/sslh
|
|
|
|
# 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
|
2013-07-10 17:12:42 -04:00
|
|
|
# 2010-03-20
|
|
|
|
#
|
2013-07-10 17:11:40 -04:00
|
|
|
#
|
|
|
|
# chkconfig: 2345 13 87
|
2013-07-10 17:12:42 -04:00
|
|
|
#
|
2013-07-10 17:11:40 -04:00
|
|
|
# description: sslh - a daemon switching incoming connection between SSH and SSL/HTTPS servers
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/init.d/functions
|
|
|
|
|
|
|
|
# ./sslh -p 0.0.0.0:8443 -l 127.0.0.1:443 -s 127.0.0.1:22
|
|
|
|
|
2013-07-10 17:12:42 -04:00
|
|
|
SSLH="/usr/local/sbin/sslh"
|
|
|
|
PIDFILE="/var/run/sslh"
|
2013-07-10 17:11:40 -04:00
|
|
|
|
2013-07-10 17:13:32 -04:00
|
|
|
OPTIONS="-p 0.0.0.0:8443 --ssl 127.0.0.1:443 --ssh 127.0.0.1:22"
|
2013-07-10 17:11:40 -04:00
|
|
|
|
|
|
|
if [ -f /etc/sysconfig/sslh ]; then
|
|
|
|
. /etc/sysconfig/sslh
|
|
|
|
fi
|
|
|
|
|
|
|
|
start() {
|
|
|
|
echo -n "Starting SSL-SSH-Switch: "
|
|
|
|
if [ -f $PIDFILE ]; then
|
|
|
|
PID=`cat $PIDFILE`
|
|
|
|
echo sslh already running: $PID
|
|
|
|
exit 2;
|
|
|
|
else
|
|
|
|
daemon $SSLH $OPTIONS
|
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
[ $RETVAL -eq 0 ] && touch $PIDFILE
|
|
|
|
return $RETVAL
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo -n "Shutting down SSL-SSH-Switch: "
|
|
|
|
echo
|
|
|
|
killproc sslh
|
|
|
|
echo
|
|
|
|
rm -f $PIDFILE
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status sslh
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: {start|stop|status|restart}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
exit $?
|
|
|
|
|
2013-07-10 17:12:42 -04:00
|
|
|
|
|
|
|
|