The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Previous Message  |  Next Message 
 QMail/VPopMail cron enhancement
Author: .daniel.schrock 
Date:   22-07-02 21:15

My mail server is running Qmail/Vpopmail and my users home directories, as well as the vpopmail directory, are nfs mounted.
This has been very successful so far, but one thing has caused problems...
When the clearopensmtp cronjob runs, it floods my mailbox (which is not nfs mounted- I use local home dirs for admins) with cron errors if i'm doing something with fileserver and /home is not mounted.
In order to maintain the functionality of the job, but reduce the notification frequency, I created a script that some of you may be interested in.

<b>/admin/bin/vpopclear.sh :</b>

#!/bin/sh

<b>#Set up the initial variables</b>
BASEDIR=/home/vpopmail
BINDIR=${BASEDIR}/bin
EXECARGS='2>&1 > /dev/null'
TESTFILE=/tmp/nohome
ALERTFILE=/tmp/pagermailed
PAGEADDR='<emailaddress>'

<b>#Test for the vpopmail directory</b>
if [ -d ${BASEDIR} ]; then

<b>#if found, test if was missing last time it ran and remove</b>
if [ -f ${TESTFILE} ]; then
rm ${TESTFILE}
rm ${ALERTFILE}
fi

<b>#run the clearopensmtp process</b>
${BINDIR}/clearopensmtp ${EXECARGS}
exit 0
else
<b>#otherwise, check for the /tmp/nohome file. exit if it is found... we've already be notified</b>
if [ -f ${TESTFILE} ]; then
exit 0
else
<b>#notify us that /home is not mounted and clearopensmtp can't run.</b>
/usr/bin/mail -s '/home not mounted!' $PAGEADDR << EOF
ClearOpenSMTP unable to run!
EOF
touch ${TESTFILE}
touch ${ALERTFILE}
exit 0
fi
fi


Then modify your crontab to reflect the new script:

# vpop maintenance
#9-59,10 * * * * root /home/vpopmail/bin/clearopensmtp 2>&1 > /dev/null
9-59,10 * * * * root /admin/bin/vpopclear.sh

Feel free to modify this script to your liking.
Let me know of any ideas/suggestions you may have to make it better.

 Reply To This Message  |  Forum List  |  Flat View   Newer Topic  |  Older Topic 

 Topics Author  Date
 QMail/VPopMail cron enhancement   new
.daniel.schrock 22-07-02 21:15 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org