diff options
Diffstat (limited to 'network/sslh/rc.sslh')
-rw-r--r-- | network/sslh/rc.sslh | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/network/sslh/rc.sslh b/network/sslh/rc.sslh index 38b4a027a4..74c95ca56d 100644 --- a/network/sslh/rc.sslh +++ b/network/sslh/rc.sslh @@ -1,47 +1,53 @@ -#! /bin/sh +#!/bin/sh +# +# /etc/rc.d/rc.sslh +# +# Start/stop/restart the sslh daemon. +# -# The prefix is normally filled by make install. If -# installing by hand, fill it in yourself! -NAME=sslh -PREFIX=/usr -DAEMON=$PREFIX/bin/${NAME} -CONFIG=/etc/sslh/sslh.conf +NAME="sslh" +config="/etc/${NAME}/${NAME}.cfg" +pidfile="/var/run/${NAME}.pid" -start() -{ - pid=`pidof -o %PPID sslh` - if [[ -z $pid ]]; then - echo "Start services: sslh" - $DAEMON -F ${CONFIG} - logger -t ${tag} -p ${facility} -i 'Started sslh' - else - echo "Service is running." - fi +start() { + if [[ -z $(pidof -o %PPID $NAME) ]]; then + rm $pidfile &>/dev/null + fi + + if [ ! -f $pidfile ]; then + echo "Start services: $NAME" + ${NAME} -F $config >/dev/null 2>&1 + else + echo "Services $NAME already running." + fi } -stop() -{ - echo "Stop services: sslh" - killall -9 ${NAME} - logger -t ${tag} -p ${facility} -i 'Stopped sslh' +stop() { + if [ -f $pidfile ]; then + echo "Stop services: $NAME" + kill $(cat $pidfile) >/dev/null 2>&1 + rm $pidfile &>/dev/null + else + echo "Services $NAME is not running." + fi } +restart() { + stop + sleep 2 + start +} -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - sleep 5 - start - ;; - *) - echo "Usage: /etc/rc.d/rc.sslh {start|stop|restart}" >&2 - ;; +case $1 in +'start') + start + ;; +'stop') + stop + ;; +'restart') + restart + ;; +*) + echo "Usage $0 {start|stop|restart}" esac - -exit 0 |