File perdition.init of Package perdition
#!/bin/sh
#
# Copyright © 2011 Christian Wittmer
#
# Authors: Christian Wittmer <chris@computersalat.de>
#
# /etc/init.d/perdition
# and its symbolic link
# /(usr/)sbin/rcperdition
#
### BEGIN INIT INFO
# Provides: perdition
# Required-Start: $local_fs $remote_fs $syslog $network
# Should-Start:
# Required-Stop: $local_fs $remote_fs $syslog $network
# Should-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: perdition POP3/IMAP4 proxy
# Description: Start perdition POP3/IMAP4 proxy server
### END INIT INFO
# Note on runlevels:
# 0 - halt/poweroff 6 - reboot
# 1 - single user 2 - multiuser without network exported
# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm)
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 0
fi
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# This is our service name
SERVICE=`basename $0`
if [ -L $0 ]; then
SERVICE=`find $0 -name $SERVICE -printf %l`
SERVICE=`basename $SERVICE`
fi
[ -f /etc/${SERVICE}/${SERVICE}.conf ] || exit 1
# Source service configuration.
if [ -f /etc/sysconfig/$SERVICE ]; then
. /etc/sysconfig/$SERVICE
else
echo "$SERVICE: configfile /etc/sysconfig/$SERVICE does NOT exist !"
exit 1
fi
# Please do not edit the values below.
# Rather, please edit /etc/sysconfig/perdition
FLAGS="${FLAGS:=}"
POP3="${POP3:=yes}"
POP3_FLAGS="${POP3_FLAGS:=}"
POP3S="${POP3S:=yes}"
POP3S_FLAGS="${POP3S_FLAGS:=}"
IMAP4="${IMAP4:=yes}"
IMAP4_FLAGS="${IMAP4_FLAGS:=}"
IMAP4S="${IMAP4S:=yes}"
IMAP4S_FLAGS="${IMAP4S_FLAGS:=}"
RETVAL=0
RETVAL1=0
RETVAL2=0
RETVAL3=0
RETVAL4=0
start() {
echo -n $"Starting $SERVICE: "
if [ "$POP3" = "yes" ]; then
daemon /usr/sbin/perdition.pop3 --pid_file=/var/run/perdition/perdition.pop3 $FLAGS $POP3_FLAGS
RETVAL1=$?
fi
if [ "$POP3S" = "yes" ]; then
daemon /usr/sbin/perdition.pop3s --pid_file=/var/run/perdition/perdition.pop3s $FLAGS $POP3S_FLAGS
RETVAL2=$?
fi
if [ "$IMAP4" = "yes" ]; then
daemon /usr/sbin/perdition.imap4 --pid_file=/var/run/perdition/perdition.imap4 $FLAGS $IMAP4_FLAGS
RETVAL3=$?
fi
if [ "$IMAP4S" = "yes" ]; then
daemon /usr/sbin/perdition.imaps --pid_file=/var/run/perdition/perdition.imaps $FLAGS $IMAP4S_FLAGS
RETVAL4=$?
fi
RETVAL=$[ $RETVAL1 + $RETVAL2 + $RETVAL3 + $RETVAL4 ]
[ $RETVAL -eq 0 ] && echo_success || echo_failure
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SERVICE
echo
return $RETVAL
}
stop() {
echo -n $"Shutting down $SERVICE: "
if [ "$POP3" = "yes" ]; then
killproc perdition.pop3
RETVAL1=$?
fi
if [ "$POP3S" = "yes" ]; then
killproc perdition.pop3s
RETVAL2=$?
fi
if [ "$IMAP4" = "yes" ]; then
killproc perdition.imap4
RETVAL3=$?
fi
if [ "$IMAP4S" = "yes" ]; then
killproc perdition.imaps
RETVAL4=$?
fi
RETVAL=$[ $RETVAL1 + $RETVAL2 + $RETVAL3 + $RETVAL4 ]
[ $RETVAL -eq 0 ] && echo_success || echo_failure
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$SERVICE
echo
return $RETVAL
}
restart() {
stop
start
}
rhstatus() {
[ "$POP3" = "yes" ] && status perdition.pop3
[ "$POP3S" = "yes" ] && status perdition.pop3s
[ "$IMAP4" = "yes" ] && status perdition.imap4
[ "$IMAP4S" = "yes" ] && status perdition.imaps
}
condrestart() {
[ -e /var/lock/subsys/$SERVICE ] && restart || :
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
restart
;;
condrestart)
condrestart
;;
status)
rhstatus
;;
*)
echo $"Usage: $SERVICE {start|stop|restart|reload|condrestart|status}"
RETVAL=1
esac
exit $RETVAL