#!/bin/sh #---------------------------------------------------------------------------- # /etc/init.d/courier - courier init script for eisfair-1 and eisfair-2 # # Copyright (c) 2004 Jens Vehlhaber # # Creation: 2006-04-17 jv # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include configuration . /etc/config.d/vmail # default value nreturn="0" ### ------------------------------------------------------------------------- ### start/stop and failure message color output ### ------------------------------------------------------------------------- COLOR_RED='\033[1;31m' COLOR_NRM='\033[0;39m' log_end_msg () { echo -n " " if [ "$1" -eq 0 ] then echo -e "\033[300C\033[$[7]D [ OK ]" elif [ "$1" -eq 9 ] then echo -e "\033[300C\033[$[9]D disabled" else echo -e "\033[300C\033[$[7]D [${COLOR_RED}fail${COLOR_NRM}]" fi } ### ------------------------------------------------------------------------- ### main ### ------------------------------------------------------------------------- case "$1" in start) echo -n " * Starting Courier ... " /usr/sbin/authdaemond start /usr/local/courier/imapd.rc start /usr/local/courier/pop3d.rc start if [ "$COURIER_POP3IMAP_TLS" = "yes" ] then /usr/local/courier/imapd-ssl.rc start /usr/local/courier/pop3d-ssl.rc start fi if [ -f /usr/local/courier/sqwebmaild.rc ] then /usr/local/courier/sqwebmaild.rc start fi log_end_msg 0 ;; stop) echo -n " * Stopping Courier ... " /usr/sbin/authdaemond stop /usr/local/courier/imapd.rc stop /usr/local/courier/pop3d.rc stop /usr/local/courier/imapd-ssl.rc stop /usr/local/courier/pop3d-ssl.rc stop if [ -f /usr/local/courier/sqwebmaild.rc ] then /usr/local/courier/sqwebmaild.rc stop fi log_end_msg 0 ;; restart) $0 stop if [ "$START_COURIER" = 'yes' ] then sleep 1 $0 start fi ;; status) if [ ! "$START_COURIER" = "yes" ] then echo -n " POP3/IMAP " log_end_msg 9 exit 0 fi if [ -z "`netstat -xnl | grep '/var/spool/authdaemon/socket.tmp'`" ] then echo -n " Authdaemon " log_end_msg 1 exit 1 fi echo -n " IMAP " if [ -z "`netstat -tnl | grep ':143 '`" ] then log_end_msg 1 else log_end_msg 0 fi echo -n " POP3 " if [ -z "`netstat -tnl | grep ':110 '`" ] then log_end_msg 1 else log_end_msg 0 fi echo -n " IMAP-TLS " if [ ! "$COURIER_POP3IMAP_TLS" = 'yes' ] then log_end_msg 9 else if [ -z "`netstat -tnl | grep ':993 '`" ] then log_end_msg 1 else log_end_msg 0 fi fi echo -n " POP3-TLS " if [ ! "$COURIER_POP3IMAP_TLS" = 'yes' ] then log_end_msg 9 else if [ -z "`netstat -tnl | grep ':995 '`" ] then log_end_msg 1 else log_end_msg 0 fi fi ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac ### ------------------------------------------------------------------------- exit $nreturn