| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# mysqmail-postfix-logger Logs postfix traffic to MySQL |
| 4 |
# |
| 5 |
# chkconfig: 345 99 00 |
| 6 |
# description: mysqmail-postfix-logger logs all the traffic of your MTA |
| 7 |
# to a MySQL database in order to keep monthly score boards in DTC. |
| 8 |
# processname: mysqmail-postfix-logger |
| 9 |
# pidfile: /var/run/mysqmail-postfix-logger.pid |
| 10 |
# config: /etc/mysqmail.conf |
| 11 |
# |
| 12 |
# Based on Postfix startup script distributed in Fedora |
| 13 |
|
| 14 |
. /etc/rc.d/init.d/functions |
| 15 |
|
| 16 |
PATH=$PATH:/bin:/usr/bin:/usr/sbin |
| 17 |
DESC="MySQMail postfix logger" |
| 18 |
NAME=mysqmail-postfix-logger |
| 19 |
DAEMON=/usr/sbin/${NAME} |
| 20 |
PID_FILE=/var/run/${NAME}.pid |
| 21 |
|
| 22 |
if [ ! -x ${DAEMON} ] ; then |
| 23 |
echo "${DAEMON} not executable or not present!" |
| 24 |
exit 1 |
| 25 |
fi |
| 26 |
if [ ! -f /etc/mysqmail.conf ] ; then |
| 27 |
echo "Config file /etc/mysqmail.conf not found: exiting" |
| 28 |
exit 1 |
| 29 |
fi |
| 30 |
|
| 31 |
status -p $PID_FILE ${NAME} >/dev/null 2>&1 |
| 32 |
running=$? |
| 33 |
|
| 34 |
start() { |
| 35 |
# Start daemons. |
| 36 |
echo -n $"Starting ${DESC}: " |
| 37 |
daemon ${DAEMON} |
| 38 |
RETVAL=$? |
| 39 |
echo "" |
| 40 |
return $RETVAL |
| 41 |
} |
| 42 |
|
| 43 |
stop() { |
| 44 |
# Stop daemons. |
| 45 |
echo -n $"Stopping ${DESC}: " |
| 46 |
killproc -p $${PID_FILE} ${NAME} && success || failure $"$prog stop" |
| 47 |
RETVAL=$? |
| 48 |
echo "" |
| 49 |
return $RETVAL |
| 50 |
} |
| 51 |
|
| 52 |
# See how we were called. |
| 53 |
case "$1" in |
| 54 |
start) |
| 55 |
if [ $running -eq 0 ] ; then |
| 56 |
exit 0 |
| 57 |
fi |
| 58 |
start |
| 59 |
;; |
| 60 |
stop) |
| 61 |
if ! [ $running -eq 0 ] ; then |
| 62 |
exit 0 |
| 63 |
fi |
| 64 |
stop |
| 65 |
;; |
| 66 |
restart) |
| 67 |
stop |
| 68 |
start |
| 69 |
;; |
| 70 |
status) |
| 71 |
status -p $pidfile dtc-xen |
| 72 |
;; |
| 73 |
condrestart) |
| 74 |
if ! [ $running -eq 0 ] ; then |
| 75 |
exit 0 |
| 76 |
fi |
| 77 |
stop |
| 78 |
start |
| 79 |
;; |
| 80 |
*) |
| 81 |
echo $"Usage: $0 {start|stop|restart|status|condrestart}" |
| 82 |
exit 2 |
| 83 |
esac |
| 84 |
|
| 85 |
exit $? |