Qmail опашка изтриване
#!/bin/bash
echo "Qmail needs to be STOPPED!!!";
cd /var/qmail/queue/mess
if [ "$1" == "" ] || [ "$1" == "help" ] || [ "$1" == "--help" ]; then
echo "ex: $0 option=string rm=no|yes";
echo "Default rm is set to 'no' and $0 only print messages containg specified string";
echo;
echo " Options are:";
echo " subject='string' - If Subject containing 'string'";
echo " to='string' - If To: line containing 'string'";
echo " from='string' - If From: line containig 'string'";
echo " mess='string' - Looking in the whole message";
echo " help - print this message and exit";
echo;
exit 1
fi
#echo $2;
RM1=`echo $2 | cut -d "=" -f 2`;
#echo $RM1;
RM2=`echo $2 | cut -d "=" -f 1`;
#echo $RM2;
#echo $1;
STR1=`echo $1 | cut -d "=" -f 2`;
#echo $STR1;
STR2=`echo $1 | cut -d "=" -f 1`;
#echo $STR2;
echo "Enter 'yes' to start";
read key
if [ "$key" == "yes" ]; then
echo "Start...";
else
echo "Canceled...";
exit 1
fi
case "$STR2" in
subject )
GREP=`grep "^Subject: " * -r -m 1 | grep "$STR1" | awk {'print $1'} | cut -d "/" -f 2 | cut -d ":" -f 1`;
;;
to )
GREP=`grep "^To: " * -r -m 1 | grep "$STR1" | awk {'print $1'} | cut -d "/" -f 2 | cut -d ":" -f 1`;
;;
from )
GREP=`grep "^From: " * -r -m 1 | grep "$STR1" | awk {'print $1'} | cut -d "/" -f 2 | cut -d ":" -f 1`;
;;
mess )
GREP=`grep "$STR1" * -r -m 1 | awk {'print $1'} | cut -d "/" -f 2 | cut -d ":" -f 1`;
;;
* )
echo "'$STR2' is not an option!!!";
echo "See $0 help for options";
exit 1
;;
esac
echo "Deleting messages with '${STR2}' line like '${STR1}'...";
for i in $GREP; do
FIND=`find /var/qmail/queue/ -name $i`;
if [ "$RM1" == "yes" ]; then
for a in $FIND; do
echo "Deleting: $a";
rm -vf $a
done
else
for a in $FIND; do
echo "Not Deleted: $a";
done
fi
done
echo "Done!";
Няма коментари
Обратно към списъка със статиите
Тази страница последно е променяна на 2025-10-30 04:37:30