Article View: alt.privacy.anon-server
Article #307535Re: mailq delete script
From: elvis-85781
Date: Sat, 25 Jan 2020 00:34
Date: Sat, 25 Jan 2020 00:34
108 lines
3759 bytes
3759 bytes
On 2020-01-23, inwtx <noreply@inwtx.net> wrote:
>
> If you want to delete just the eurovibes.org mail stuck
> in your mailq, you can use the script below:
>
>
> #!/bin/bash
> #
> # DeleteMailqByName.sh
> #
> # This scripts deletes entries in the mailq via a name in the mailq record.
> # Be exact on the text to search for (eurovibes.org, etc).
> # Format: ./DeleteMailqByName.sh eurovibes.org
>
>
> filePath=${0%/*} # current file path
>
> inputrem="$1"
>
> if [[ $1 == "" ]]; then
> echo "Address of remailer required!"
> exit 0
> fi
>
> mailq > $filePath/DeleteMailqByName.txt
>
> cat /dev/null > $filePath/DeleteMailqByName.txt2
>
> sed -i "1d" $filePath/DeleteMailqByName.txt
> sed -i '$d' $filePath/DeleteMailqByName.txt
>
> while read line1; do
> if [[ ! $line1 = "" ]]; then
> tr -d '\012' <<<$line1 >> $filePath/DeleteMailqByName.txt2
> else
> echo "$line1" >> $filePath/DeleteMailqByName.txt2
> fi
> done< $filePath/DeleteMailqByName.txt
>
> awk -vS= '$inputrem' $filePath/DeleteMailqByName.txt2 > $filePath/DeleteMailqByName.txt3
>
> awk '{ print $1 }' $filePath/DeleteMailqByName.txt3 > $filePath/DeleteMailqByName.txt4
>
> sed -i 's/\*//g' DeleteMailqByName.txt4
>
> while read line1; do
> postsuper -d $line1
> done< $filePath/DeleteMailqByName.txt4
>
> rm $filePath/DeleteMailqByName.txt
> rm $filePath/DeleteMailqByName.txt2
> rm $filePath/DeleteMailqByName.txt3
> rm $filePath/DeleteMailqByName.txt4
>
> exit 0
That has some similarity to a post from 2015 (not by me).
Here is a script I wrote just for such pesky mailq entries. Put it in a file /etc/deletemailq.sh, 'chmod 755 deletemailq.sh' it and run it like this:
./deletemailq.sh pinger@anonusa.net
It will only pick out the pinger@anonusa.net mailq records and remove them.
#!/bin/bash
#
# deletemailq.sh
# Delete mailq by string within mailq record
# ./deletemailq.sh pinger@anonusa.net
#
export PATH=$PATH:/sbin
export PATH=$PATH:/bin
export PATH=$PATH:/usr/sbin
filePath=${0%/*} # current file path
remailerid="$1"
if [ ${#remailerid} = 0 ]; then
echo "Remailer name or address must be appended to end for this process to start!"
exit 0
fi
mailq > $filePath/tempmq.txt
sed -i '/-Arrival Time-/d' $filePath/tempmq.txt # rid of title and trailer lines
sed -i '/Kbytes in/d' $filePath/tempmq.txt
while read -r line; do
var1stline=$line # 1st line
read -r line
var2ndline=$line #2nd line
read -r line
var3rdline=$line #3rd line
read -r line # blank line between
mailqstr="$var1stline $var2ndline $var3rdline" # all 3 lines merged into one
if [[ $(grep -c $remailerid <<<$mailqstr) -gt 0 ]]; then # is passed string in mailq record?
qID=$(cut -d' ' -f1 <<<$mailqstr) # extract 'Queue ID' to delete
postsuper -d "$qID" # yes - delete it
fi
done < $filePath/tempmq.txt
rm $filePath/tempmq.txt
exit 0
Technical Details
Message-ID:
<slrnr2n38e.b0b.elvis-85781@notatla.org.uk>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mailReferences:
<r0cpje$17r$1@news.mixmin.net>Show Full Headers
Complete Article Headers
Message-ID: <slrnr2n38e.b0b.elvis-85781@notatla.org.uk> Subject: Re: mailq delete script Date: Sat, 25 Jan 2020 00:34:22 GMT From: elvis-85781@notatla.org.uk References: <r0cpje$17r$1@news.mixmin.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail Newsgroups: alt.privacy.anon-server X-Noarchive: yes X-No-Archive: yes User-Agent: slrn/1.0.3 (Linux) Lines: 108 X-Complaints-To: abuse@blocknews.net Nntp-Posting-Date: Sat, 25 Jan 2020 00:34:22 UTC Organization: blocknews - www.blocknews.net