Per avvisare gli utenti email che lo spazio a disposizione per l'account di posta elettronica sta per essere superato ho reperito il seguente script che controlla lo spazio delle caselle email ed invia all'utente un avviso
http://forum.parallels.com/showthread.php?t=106635
Come devo modificare lo script per fare in modo che i messaggi vengono inviati solo qualora $HARDQUOTA è + grande di 0 ?
inoltre lo script mi dà il seguente errore: mail: invalid option -- a
codice:
#! /bin/sh
# Mail quota reaching it's limit e-mail notification
# script for Plesk 9.3+ / Plesk 10 & Qmail
# Modified by "Scy" from the original script
# provided by "azur99" in Plesk forum:
# http://forum.parallels.com/showthread.php?t=71666
#setenv QMAILUSER 'do-not-reply'
MAILROOT=/var/qmail/mailnames
cd $MAILROOT > /dev/null
for DIR in *.*;do
cd $MAILROOT/$DIR
for MAILBOX in * ;do
if [ -d $MAILBOX ]
then
# look for specific mailbox quota file and set mailbox softquota
QUOTAFILE=$MAILROOT/$DIR/$MAILBOX/Maildir/maildirsize
# Fetching mailbox quota size in bytes
HARDQUOTA=$((`head -1 $QUOTAFILE | cut -d S -f1`))
HARDQUOTA=$(($HARDQUOTA+4096))
# Fetching space used by mailbox in bytes
MBOXSPACE=$((`tail -n +2 $QUOTAFILE | cut -c1-12 | paste -sd+|bc`))
# Calculate the quota limit required for mail warning (95% for default)
SOFTQUOTA=$((95 * $HARDQUOTA / 100))
# Calculate mailbox usage percentage (with two decimals)
MBOXPERCENT=$(echo "scale=2; $MBOXSPACE*100/$HARDQUOTA" | bc)
# Check if the mailbox is full enough for warning, and if, send the warning mail
if [ $HARDQUOTA -gt 0 -a $MBOXSPACE -gt $SOFTQUOTA ]; then
# Let's generate the values in megabytes (with two decimals)
HARDQUOTA=$(echo "scale=2; $HARDQUOTA/1048576" | bc)
if [ "$(echo $HARDQUOTA | cut -c1)" = "." ] ; then HARDQUOTA="0"$HARDQUOTA
fi
MBOXSPACE=$(echo "scale=2; $MBOXSPACE/1048576" | bc)
if [ "$(echo $MBOXSPACE | cut -c1)" = "." ] ; then MBOXSPACE="0"$MBOXSPACE
fi
mail -s "E-mail quota warning!" $MAILBOX@$DIR -a "Content-Type: text/plain; charset=ISO-8859-1" << EOF
Dear mailbox user,
Your e-mail '$MAILBOX@$DIR' is about to reach its maximum quota and is already using $MBOXSPACE MB ($MBOXPERCENT%) out of the maximum quota $HARDQUOTA MB.
We would kindly suggest you to delete some older messages and purge them to free some disk space for mailbox. In case the quota limit is reached, you won't be able to receive any new messages and the sender will receive 'mail quota exceeded' notifications.
The other option is to configure POP3 mail client (e.g. Microsoft Outlook, Mozilla Thunderbird or Mac Mail) that would empty the server mailbox every time the mail account is read and move the old mail to local disk of your own computer.
PS. This is an automated message and should not be replied. If you require any assistance, please contact to your mail server provider.
EOF
fi
fi
done;
done;
Grazie per un consiglio