#!/bin/sh # # /etc/rc.d/rc.sslh # # Start/stop/restart the sslh daemon. # NAME="sslh" config="/etc/${NAME}/${NAME}.cfg" pidfile="/var/run/${NAME}.pid" 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() { 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') restart ;; *) echo "Usage $0 {start|stop|restart}" esac