#!/bin/sh # # qkillto # John Simpson # 2009-11-30 # # Finds messages in a qmail queue where the recipient contains a certain # regex, and removes them from the queue. # # ********************************************************************* # *** *** # *** DANGER! DANGER! DANGER! *** # *** *** # *** DO NOT RUN THIS WHILE ANY QMAIL-RELATED PROGRAMS ARE RUNNING! *** # *** *** # *** DANGER! DANGER! DANGER! *** # *** *** # ********************************************************************* # ############################################################################### # # Copyright (C) 2003,2007,2009 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### VQ="/var/qmail" NL=`mktemp -t -p /tmp nlist.XXXXXXXXXXXX` || exit 1 find $VQ/queue/local $VQ/queue/remote -type f -print0 \ | xargs -0 grep -l "${1:?No pattern specified}" \ | sed 's/^.*\///' > $NL for n in `cat "$NL"` do echo Deleting message $n rm -f $VQ/queue/bounce/$n \ $VQ/queue/info/*/$n \ $VQ/queue/intd/$n \ $VQ/queue/local/*/$n \ $VQ/queue/mess/*/$n \ $VQ/queue/remote/*/$n \ $VQ/queue/todo/$n done rm "$NL"