ansible-role-postfix/files/remove_queued_messages.sh

13 lines
376 B
Bash
Raw Normal View History

2022-10-11 09:19:06 +02:00
#!/bin/bash
2023-11-02 16:26:19 +01:00
set -euo pipefail
2022-10-11 09:19:06 +02:00
if [[ "$1" == "" ]]
then
echo "Indicate a string to search in the postqueue."
exit 54
fi
postqueue -p | grep -v '^-' | sed ':a;N;$!ba;s/\n\n/ENTER/g' | sed ':a;N;$!ba;s/\n/ /g' | sed 's/ENTER/\n/g' | grep "$1" |awk '{print($1)}' | while read -r KMSGID
do
echo "Removing message with ID '${KMSGID}'..."
postsuper -d "$KMSGID"
2023-11-02 16:26:19 +01:00
done