Commit 9c1d4d9b authored by ale's avatar ale
Browse files

Add minimal Postfix queue management scripts

That support multiple instances
parent 5d2af2b2
#!/bin/bash
#
# Filter out messages matching a specific criteria.
#
instances=postfix-out
do_delete=0
sender=
while [ $# -gt 0 ]; do
case "$1" in
-i)
instances="$instances $2"
shift
;;
-d)
do_delete=1
;;
-*)
echo "Unknown option '$1'" >&2
exit 2
;;
*)
sender="$1"
;;
esac
shift
done
if [ -z "$sender" ]; then
echo "Usage: pqgrep [<options>] <sender>" >&2
exit 2
fi
if [ "$instances" = "all" ]; then
instances=$(postmulti -l | awk '$1 != "-" {print $1}')
fi
cmd="cat"
if [ $do_delete -eq 1 ]; then
cmd="xargs -n 1 postmulti -i $instance -x postsuper -d"
fi
for instance in $instances; do
postmulti -i $instance -x mailq \
| awk "\$7 == \"${sender}\" {print $1}" \
| $cmd
done
#!/bin/bash
#
# Print a summary of a Postfix queue.
#
instances=postfix-out
while [ $# -gt 0 ]; do
case "$1" in
-i)
instances="$instances $2"
shift
;;
-*)
echo "Unknown option '$1'" >&2
exit 2
;;
*)
echo "Too many arguments" >&2
exit 2
;;
esac
shift
done
if [ "$instances" = "all" ]; then
instances=$(postmulti -l | awk '$1 != "-" {print $1}')
fi
for instance in $instances; do
echo
echo "* $instance:"
postmulti -i $instance -x mailq \
| awk '/^[A-Z0-9]+/ {count[$7]++} END {for(i in count){ print i, count[i] }}' \
| sort -n -k2 \
| column -t
done
......@@ -49,6 +49,15 @@
dest: /etc/systemd/system/postfix@.service.d/override.conf
mode: 0444
- name: Install Postfix queue management scripts
copy:
src: "{{ item }}"
dest: "/usr/local/bin/{{ item }}"
mode: 0755
loop:
- pqgrep
- pqsummary
- include_tasks: frontend.yml
when: float_enable_mail_frontend
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment