Created
December 28, 2012 22:30
-
-
Save stwalkerster/4402579 to your computer and use it in GitHub Desktop.
Postfix queue management script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
app="whiptail --backtitle 'Postfix Queue Manager - stwalkerster.net Cluster' --clear --nocancel" | |
while true; do | |
queue=`ls /var/spool/postfix/hold/` | |
menulist="" | |
for i in $queue; do | |
sender=`postcat -h /var/spool/postfix/hold/$i | grep "From: " | sed "s/From: //" | sed 's/"//g'` | |
menuitem=" "$i" \""$sender"\" " | |
menulist=$menulist$menuitem | |
done | |
command=$app' --menu "Postfix Queue Manager" 40 80 30 '$menulist' quit "Quit this application"' | |
choice=$( eval $command 3>&2 2>&1 1>&3 ) | |
if [ "$choice" == "quit" ] | |
then | |
break | |
fi | |
while true; do | |
from=`postcat -h /var/spool/postfix/hold/$choice | grep "From: " | sed 's/"//g'` | |
subject=`postcat -h /var/spool/postfix/hold/$choice | grep "Subject: " | sed 's/"//g'` | |
command=$app' --menu "Postfix Queue Item '$choice'\n'$from'\n'$subject'" 20 80 10 ignore "Ignore this message" view "View this message content" headers "View this message headers" envelope "View the envelope" requeue "Requeue this message for delivery" delete "Delete this message"' | |
action=$( eval $command 3>&2 2>&1 1>&3 ) | |
case "$action" in | |
ignore) | |
break | |
;; | |
view) | |
postcat -b /var/spool/postfix/hold/$choice | less | |
;; | |
headers) | |
postcat -h /var/spool/postfix/hold/$choice | less | |
;; | |
envelope) | |
postcat -e /var/spool/postfix/hold/$choice | less | |
;; | |
requeue) | |
postsuper -r $choice | |
break | |
;; | |
delete) | |
postsuper -d $choice | |
break | |
;; | |
*) | |
;; | |
esac | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment