#!/bin/sh
# Sample stunnel SysV startup file
# Copyright by Michal Trojnara 2002,2007,2008

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=@prefix@/bin/stunnel
PIDFILE=@prefix@/var/run/stunnel/stunnel.pid

test -f $DAEMON || exit 0

case "$1" in
    start)
        echo -n "Starting universal SSL tunnel: stunnel"
        $DAEMON || echo -n " failed"
        echo "."
        ;;
    stop)
        echo -n "Stopping universal SSL tunnel: stunnel"
        if test -r $PIDFILE; then
            kill `cat $PIDFILE` 2> /dev/null || echo -n " failed"
        else
            echo -n " no PID file"
        fi
        echo "."
        ;;
     restart|force-reload)
        echo "Restarting universal SSL tunnel"
        $0 stop
        sleep 1
        $0 start
        echo "done."
        ;;
    *)
        N=${0##*/}
        N=${N#[SK]??}
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

