2006-02-23 16:26:10 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# /etc/rc.d/stunnel: start/stop stunnel daemon
|
|
|
|
#
|
|
|
|
|
2015-03-12 12:01:40 +01:00
|
|
|
SSD=/sbin/start-stop-daemon
|
|
|
|
PROG=/usr/sbin/stunnel
|
2019-03-31 13:25:01 +02:00
|
|
|
NAME=stunnel
|
2015-03-12 12:01:40 +01:00
|
|
|
PID=/var/run/stunnel/stunnel.pid
|
2015-04-18 09:47:39 +02:00
|
|
|
CFG=/etc/stunnel.conf
|
2015-03-12 12:01:40 +01:00
|
|
|
|
2006-02-23 16:26:10 +01:00
|
|
|
CRT=/etc/ssl/certs/stunnel.crt
|
|
|
|
KEY=/etc/ssl/keys/stunnel.key
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
start)
|
|
|
|
if [ ! -s $KEY -o ! -s $CRT ]; then
|
2006-02-25 16:42:56 +01:00
|
|
|
/usr/bin/mksslcert $KEY $CRT
|
2006-02-23 16:26:10 +01:00
|
|
|
fi
|
2015-04-18 09:47:39 +02:00
|
|
|
$SSD --start --pidfile $PID --exec $PROG -- $CFG
|
2006-02-23 16:26:10 +01:00
|
|
|
;;
|
|
|
|
stop)
|
2019-03-31 13:25:01 +02:00
|
|
|
$SSD --stop --retry 10 --name $NAME --pidfile $PID
|
2006-02-23 16:26:10 +01:00
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
2015-03-12 12:01:40 +01:00
|
|
|
status)
|
2019-03-31 13:25:01 +02:00
|
|
|
$SSD --status --name $NAME --pidfile $PID
|
2015-03-12 12:01:40 +01:00
|
|
|
case $? in
|
2015-04-03 12:06:03 +02:00
|
|
|
0) echo "$PROG is running with pid $(cat $PID)" ;;
|
2015-03-12 12:01:40 +01:00
|
|
|
1) echo "$PROG is not running but the pid file $PID exists" ;;
|
|
|
|
3) echo "$PROG is not running" ;;
|
|
|
|
4) echo "Unable to determine the program status" ;;
|
|
|
|
esac
|
|
|
|
;;
|
2006-02-23 16:26:10 +01:00
|
|
|
*)
|
2015-03-12 12:01:40 +01:00
|
|
|
echo "usage: $0 [start|stop|restart|status]"
|
2006-02-23 16:26:10 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
# End of file
|