#!/bin/bash
#
# stunnel-imap This script starts stunnel service of imap with
# a configuration file in /etc/stunnel/stunnel-imap.conf
#
# chkconfig: 345 88 12
#
# description: the stunnel-imap starts a SSL conection between a local
# host on port 1143 and the secure imap server on
# mail.myexample.com on port 993. The open text imap requests
# sent to the localhost to port 1143 are being encrypted and
# relayed via SSL to imaps server on another computer.
#
# processname: stunnel-imap
# config: /etc/stunnel/stunnel-imap.conf
# pidfile: /var/run/stunnel-imap.pid
#
PATH=/sbin:/bin:/usr/bin:/usr/sbin
# Source function library and networking
. /etc/init.d/functions
. /etc/sysconfig/network
prog="stunnel-imap"
[ -f /etc/stunnel/${prog}.conf ] || exit 1
# Check that we are root ... so non-root users stop here
[ `id -u` = 0 ] || exit 1
# Check that networking is up.
[ "${NETWORKING}" = "yes" ] || exit 0
[ -f /usr/sbin/${prog} ] || exit 1
RETVAL=0
start(){
echo -n $"Starting $prog: "
echo "before daemon $prog"
daemon $prog /etc/stunnel/${prog}.conf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/${prog}
return $RETVAL
}
stop(){
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${prog}
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
esac
exit $RETVAL
|