Qmail notes

From Noah.org
Revision as of 14:15, 5 February 2007 by Root (talk | contribs)
Jump to navigationJump to search

mail.sh

This is the missing mail control script. It's crude, but it works. Note that this won't fix queue problems. Look for the qfixq script.

#! /bin/sh
# Start or stop all mail services.
# Intended for a standard Qmail Rocks installation.
# Noah

case $1 in
status)
    /etc/init.d/clamd status
    /etc/init.d/spamassassin status
    /etc/init.d/imap status
    /etc/init.d/imaps status
    # Wish I could do "/usr/local/sbin/authdaemond status"
    ps auxww | grep authdaemond | grep -v "grep authdaemond"
    ps auxww | grep readproctitle | grep -v "grep readproctitle"
    /usr/bin/qmailctl stat
    ;;
spamon)
    cp /var/qmail/supervise/qmail-smtpd/run /var/qmail/supervise/qmail-smtpd/run.backup
    sed -i -e "s/^#QMAILQUEUE=.*/QMAILQUEUE=\"\/var\/qmail\/bin\/qmail-scanner-queue.pl\" ; export QMAILQUEUE/g" /var/qmail/supervise/qmail-smtpd/run
    ;;
spamoff)
    cp /var/qmail/supervise/qmail-smtpd/run /var/qmail/supervise/qmail-smtpd/run.backup
    sed -i -e "s/^QMAILQUEUE=.*/#QMAILQUEUE=\"\/var\/qmail\/bin\/qmail-scanner-queue.pl\" ; export QMAILQUEUE/g" /var/qmail/supervise/qmail-smtpd/run
    ;;
start)
    # Without this clamd won't start up sometimes
    # (clamd.log ownership gets messed up).
    #    ERROR: Problem with internal logger. Please check the permissions on the /var/log/clamav/clamd.log file.
    # I'm not sure what causes this, but this hack fixes it and
    # is probably harmless on systems that don't have this problem.
    chown `grep ^User /etc/clamd.conf | cut -d ' ' -f2` /var/log/clamav/*
    /usr/local/sbin/authdaemond start
    /etc/init.d/clamd start
    /etc/init.d/spamassassin start
    /etc/init.d/imap start
    /etc/init.d/imaps start
    svc -u /service/qmail-pop3d
    svc -u /service/qmail-smtpd
    svc -u /service/qmail-send
    /usr/bin/qmailctl start
    ;;
stop)
    /usr/bin/qmailctl stop
    svc -d /service/qmail-send
    svc -d /service/qmail-smtpd
    svc -d /service/qmail-pop3d
    /etc/init.d/imaps stop
    /etc/init.d/imap stop
    /etc/init.d/spamassassin stop
    /etc/init.d/clamd stop
    /usr/local/sbin/authdaemond stop
    ;;
lsq)
    find /var/qmail/queue -type f -exec ls -l {} \;
    ;;
*)
    cat <<HELPHERE
$0 COMMAND
status --- Show status of all mail services.
spamon  -- Enable spam/virus filtering in /var/qmail/supervise/qmail-smtpd/run.
spamoff -- Disable spam/virus filtering.
start ---- Start all mail services.
stop ----- Stop al mail services.
lsq ------ List all files in qmail queue folders.
HELPHERE
    ;;
esac
exit 0

aliases

Add this to bash aliases.

alias lsq='find /var/qmail/queue -type f -exec ls -l {} \;'