Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > 73093cb1c8f242ddaece96043c8acbb2 > files > 4

courier-authlib-0.63.0-8.mga1.src.rpm

#!/bin/sh
#
# chkconfig: 345 15 85
# description: This startup script launches the authentication daemon

### BEGIN INIT INFO
# Provides: courier-authdaemon
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 345
# Short-Description: Courier authentication daemon
# Description: This startup script launches the authentication daemon
### END INIT INFO

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

# Source courier authdaemon configuration
. /etc/courier/authdaemonrc

# Local values
NAME=courier-authdaemon
WRAPPER=courierlogger
PROGRAM=authdaemond
PIDFILE=/var/run/authdaemon.pid
LOCKFILE=/var/lock/subsys/courier-authdaemon
PFDIR=/var/spool/postfix

start() {
    # Check if it is already running
    if [ ! -f $LOCKFILE ]; then
	echo -n "Starting $NAME"
	export DEBUG_LOGIN
	daemon $WRAPPER -pid=$PIDFILE -start $LOGGEROPTS $PROGRAM
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch $LOCKFILE
	echo
    fi
    # Check if Postfix is present and make a hardlink so
    # sasl smtpd auth can work
    if [ -d $PFDIR ]; then
	if [ ! -d $PFDIR$authdaemonvar ]; then
	    echo "Creating $PFDIR$authdaemonvar"
	    mkdir -p $PFDIR$authdaemonvar
	fi
	echo "re-mouting $authdaemonvar in postfix chroot"
	mount $authdaemonvar $PFDIR$authdaemonvar -o bind
    fi
}

stop() {
    echo -n "Stopping $NAME"
    daemon $WRAPPER -pid=$PIDFILE -stop
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
    
    # delete old socket
    [ $RETVAL -eq 0 ] && rm -f $authdaemonvar/socket
    echo
    
    # if there is postfix, remove hardlink from there
    if [ -d $PFDIR ]; then
	echo "unmouting $authdaemonvar from $PFDIR$authdaemonvar"
	umount $PFDIR$authdaemonvar
    fi
}

reload() {
    echo -n "Reloading $NAME"
    daemon $WRAPPER -pid=$PIDFILE -restart
    RETVAL=$?
    echo
}

restart() {
    stop
    start
}

RETVAL=0

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    restart)
	restart
	;;
    reload)
	reload
	;;
    condrestart)
	if [ -f $LOCKFILE ]; then
	    restart
	fi
	;;
    condreload)
	if [ -f $LOCKFILE ]; then
	    reload
	fi
	;;
    status)
	status $PROGRAM
	;;
    *)
	echo $"Usage: $0 {start|stop|restart|reload|condrestart|condreload|status}"
	RETVAL=1
	;;
esac

exit $RETVAL