4 # Required-Start: $local_fs $remote_fs
5 # Required-Stop: $local_fs $remote_fs
6 # Should-Start: $syslog
8 # Default-Start: 2 3 4 5
10 # Short-Description: Start or stop stunnel 4.x (SSL tunnel for network daemons)
13 DEFAULTPIDFILE="/var/run/stunnel4.pid"
14 DAEMON=/usr/bin/stunnel4
17 FILES="/etc/stunnel/*.conf"
23 if test -f $file; then
24 CHROOT=`grep "^chroot" $file|sed "s;.*= *;;"`
25 PIDFILE=`grep "^pid" $file|sed "s;.*= *;;"`
26 if [ "$PIDFILE" = "" ]; then
27 PIDFILE=$DEFAULTPIDFILE
29 if test -f $CHROOT/$PIDFILE; then
36 if ! [ -d /var/run/stunnel4 ]; then
37 rm -rf /var/run/stunnel4
38 install -d -o stunnel4 -g stunnel4 /var/run/stunnel4
40 for file in $FILES; do
41 if test -f $file; then
43 PROCLIST=`get_pids $file`
44 if [ "$PROCLIST" ] && kill -0 $PROCLIST 2>/dev/null; then
45 echo -n "[Already running: $file] "
46 elif $DAEMON $ARGS; then
47 echo -n "[Started: $file] "
49 echo "[Failed: $file]"
50 echo "You should check that you have specified the pid= in you configuration file"
59 for file in $FILES; do
60 PROCLIST=`get_pids $file`
61 if [ "$PROCLIST" ] && kill -0 $PROCLIST 2>/dev/null; then
63 echo -n "[stopped: $file] "
68 if [ "x$OPTIONS" != "x" ]; then
72 test -f /etc/default/stunnel4 && . /etc/default/stunnel4
73 if [ "$ENABLED" = "0" ] ; then
74 echo "$DESC disabled, see /etc/default/stunnel4"
78 test -x $DAEMON || exit 0
84 echo -n "Starting $DESC: "
89 echo -n "Stopping $DESC: "
93 #force-reload does not send a SIGHUP, since SIGHUP is interpreted as a
94 #quit signal by stunnel. I reported this problem to upstream authors.
96 echo -n "Restarting $DESC: "
104 echo "Usage: $N {start|stop|force-reload|restart}" >&2