updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / sslh-git / rc.sslh
blob2a7278234a4d27816eb11d8871ca408b1d48eced
1 #!/bin/bash
3 daemon_name=sslh
5 . /etc/rc.conf
6 . /etc/rc.d/functions
7 . /etc/conf.d/$daemon_name
9 PIDFILE="/var/run/sslh.pid"
11 get_pid() {
12 cat /var/run/$daemon_name.pid
15 case "$1" in
16 start)
17 stat_busy "Starting $daemon_name daemon"
19 PID=$(get_pid)
20 if [ -z "$PID" ]; then
21 [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
22 # RUN
23 $daemon_name -u nobody -p ${LISTEN} -s ${SSH} -l ${SSL} -P /var/run/$daemon_name.pid
25 if [ $? -gt 0 ]; then
26 stat_fail
27 exit 1
28 else
29 echo $(get_pid) > /var/run/$daemon_name.pid
30 add_daemon $daemon_name
31 stat_done
33 else
34 stat_fail
35 exit 1
39 stop)
40 stat_busy "Stopping $daemon_name daemon"
41 PID=$(get_pid)
42 # KILL
43 [ ! -z "$PID" ] && kill $PID &> /dev/null
45 if [ $? -gt 0 ]; then
46 stat_fail
47 exit 1
48 else
49 rm -f /var/run/$daemon_name.pid &> /dev/null
50 rm_daemon $daemon_name
51 stat_done
55 restart)
56 $0 stop
57 sleep 3
58 $0 start
62 echo "usage: $0 {start|stop|restart}"
63 esac
65 exit 0