Subversion Repositories configs

Rev

Rev 43 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/bin/bash
#
# zarafa-gateway Zarafa Collaboration Platform's POP3/IMAP Gateway
#
# chkconfig: 345 86 24
# description: The Zarafa Gateway allows users \
#              to access their email using the POP3 or IMAP protocol.
# processname: /usr/sbin/zarafa-gateway
# config: /etc/zarafa/gateway.cfg
# pidfile: /var/run/zarafad/gateway.pid

### BEGIN INIT INFO
# Provides: zarafa-gateway
# Required-Start: $local_fs $network $remote_fs $syslog
# Required-Stop: $local_fs $network $remote_fs $syslog
# Should-Start: zarafa-server
# Should-Stop: zarafa-server
# Short-Description: Zarafa Collaboration Platform's POP3/IMAP Gateway
# Description: The Zarafa Gateway allows users
#              to access their email using the POP3 or IMAP protocol.
### END INIT INFO

GATEWAYCONFIG=/etc/zarafa/gateway.cfg
GATEWAYPROGRAM=/usr/sbin/zarafa-gateway

# Sanity checks.
[ -x $GATEWAYPROGRAM ] || exit 0

GATEWAYCONFIG_OPT=""
[ ! -z $GATEWAYCONFIG -a -f $GATEWAYCONFIG ] && GATEWAYCONFIG_OPT="-c $GATEWAYCONFIG"

[ -f /etc/sysconfig/zarafa ] && . /etc/sysconfig/zarafa
if [ -z "$ZARAFA_LOCALE" ]; then
        ZARAFA_LOCALE="C"
fi

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0
gateway=`basename $GATEWAYPROGRAM`
lockfile=/var/lock/subsys/$gateway
pidfile=/var/run/zarafad/gateway.pid

start() {
        # Start in background, always succeeds
        echo -n $"Starting $gateway: "
        install -dm0775 -o zarafa -g zarafa /var/run/zarafad
        export LC_ALL=$ZARAFA_LOCALE
        export LANG=$ZARAFA_LOCALE
        daemon $GATEWAYPROGRAM $GATEWAYCONFIG_OPT
        RETVAL=$?
        unset LC_ALL LANG
        echo
        [ $RETVAL -eq 0 ] && touch $lockfile

        return $RETVAL
}

stop() {
        echo -n $"Stopping $gateway: "
        killproc $GATEWAYPROGRAM
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile

        return $RETVAL
}

restart() {
        stop
        start
}

reload() {
        echo -n $"Restarting $gateway: "
        killproc $GATEWAYPROGRAM -SIGHUP
        RETVAL=$?
        echo

        return $RETVAL
}

# See how we were called.
case "$1" in
    start)
                start
                ;;
    stop)
                stop
                ;;
    status)
                status $gateway
                RETVAL=$?
                ;;
    restart|force-reload)
                restart
                ;;
    condrestart|try-restart)
                if [ -f ${pidfile} ]; then
                        stop
                        start
                fi
                ;;
    reload)
                reload
                ;;
    *)
                echo $"Usage: $gateway {start|stop|status|reload|restart|condrestart|force-reload|try-restart}"
                RETVAL=1
                ;;
esac

exit $RETVAL