-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmqueuerm
executable file
·65 lines (58 loc) · 1.51 KB
/
mqueuerm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# (c) 2020 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/mqueuerm
#
PROG="${0##*/}"
FORCE=0
STRINGS=0
ALL=0
usage() {
echo "${PROG} [-fsa] msgid"
exit 1
}
while getopts ':afs' opt; do
case $opt in
f) FORCE=1 ;
;;
a) ALL=1;
;;
s) STRINGS=1;
;;
*) echo "Invalid option: -$OPTARG";
usage;
;;
esac
done
if [ -z "$*" -a 0 -eq ${ALL} ]
then
usage
fi
if [ ${ALL} ];
then
FORCED=i
[[ 1 -eq ${FORCE} ]] && FORCED=""
find /var/spool/postfix/defer/ /var/spool/postfix/deferred/ -type f -exec rm -v${FORCED} {} \;
else
if [ 1 -eq ${STRINGS} ];
then
strings $(find /var/spool/postfix/defer/ /var/spool/postfix/deferred/ /var/spool/postfix/active/ -iname "*${1}*")
else
for arg in $*
do
Q="$arg"
i="${Q:0:1}"
if [ 0 -eq ${FORCE} ];
then
ls /var/spool/postfix/defer/${i}/${Q}
ls /var/spool/postfix/deferred/${i}/${Q}
ls /var/spool/postfix/active/${i}/${Q}
else
rm -f /var/spool/postfix/defer/${i}/${Q}
rm -f /var/spool/postfix/deferred/${i}/${Q}
rm -f /var/spool/postfix/active/${i}/${Q}
fi
done
fi
fi