Browse Source

Command for removing ignore rules

Bob Mottram 10 years ago
parent
commit
d49b85e988
4 changed files with 90 additions and 0 deletions
  1. 4
    0
      Makefile
  2. 1
    0
      debian/source/include-binaries
  3. BIN
      man/freedombone-unignore.1.gz
  4. 85
    0
      src/freedombone-unignore

+ 4
- 0
Makefile View File

@@ -23,6 +23,7 @@ install:
23 23
 	install -m 755 src/${APP}-rmlist ${DESTDIR}${PREFIX}/bin
24 24
 	install -m 755 src/${APP}-rmemail ${DESTDIR}${PREFIX}/bin
25 25
 	install -m 755 src/${APP}-ignore ${DESTDIR}${PREFIX}/bin
26
+	install -m 755 src/${APP}-unignore ${DESTDIR}${PREFIX}/bin
26 27
 	mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
27 28
 	install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1
28 29
 	install -m 644 man/${APP}-prep.1.gz ${DESTDIR}${PREFIX}/share/man/man1
@@ -37,6 +38,7 @@ install:
37 38
 	install -m 644 man/${APP}-rmlist.1.gz ${DESTDIR}${PREFIX}/share/man/man1
38 39
 	install -m 644 man/${APP}-rmemail.1.gz ${DESTDIR}${PREFIX}/share/man/man1
39 40
 	install -m 644 man/${APP}-ignore.1.gz ${DESTDIR}${PREFIX}/share/man/man1
41
+	install -m 644 man/${APP}-unignore.1.gz ${DESTDIR}${PREFIX}/share/man/man1
40 42
 uninstall:
41 43
 	rm -f ${PREFIX}/share/man/man1/${APP}.1.gz
42 44
 	rm -f ${PREFIX}/share/man/man1/${APP}-prep.1.gz
@@ -51,6 +53,7 @@ uninstall:
51 53
 	rm -f ${PREFIX}/share/man/man1/${APP}-rmlist.1.gz
52 54
 	rm -f ${PREFIX}/share/man/man1/${APP}-rmemail.1.gz
53 55
 	rm -f ${PREFIX}/share/man/man1/${APP}-ignore.1.gz
56
+	rm -f ${PREFIX}/share/man/man1/${APP}-unignore.1.gz
54 57
 	rm -rf ${PREFIX}/share/${APP}
55 58
 	rm -f ${PREFIX}/bin/${APP}
56 59
 	rm -f ${PREFIX}/bin/${APP}-prep
@@ -64,6 +67,7 @@ uninstall:
64 67
 	rm -f ${PREFIX}/bin/${APP}-renew-cert
65 68
 	rm -f ${PREFIX}/bin/${APP}-rmlist
66 69
 	rm -f ${PREFIX}/bin/${APP}-ignore
70
+	rm -f ${PREFIX}/bin/${APP}-unignore
67 71
 clean:
68 72
 	rm -f \#* \.#* debian/*.substvars debian/*.log
69 73
 	rm -fr deb.* debian/${APP}

+ 1
- 0
debian/source/include-binaries View File

@@ -11,3 +11,4 @@ man/freedombone-renew-cert.1.gz
11 11
 man/freedombone-rmlist.1.gz
12 12
 man/freedombone-rmemail.1.gz
13 13
 man/freedombone-ignore.1.gz
14
+man/freedombone-unignore.1.gz

BIN
man/freedombone-unignore.1.gz View File


+ 85
- 0
src/freedombone-unignore View File

@@ -0,0 +1,85 @@
1
+#!/bin/bash
2
+
3
+# Removes an ignore rule for either an email address
4
+# or text in the subject line
5
+
6
+# License
7
+# =======
8
+#
9
+# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
10
+#
11
+# This program is free software: you can redistribute it and/or modify
12
+# it under the terms of the GNU General Public License as published by
13
+# the Free Software Foundation, either version 3 of the License, or
14
+# (at your option) any later version.
15
+#
16
+# This program is distributed in the hope that it will be useful,
17
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+# GNU General Public License for more details.
20
+#
21
+# You should have received a copy of the GNU General Public License
22
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
23
+
24
+MYUSERNAME=$USER
25
+EMAIL_ADDRESS=
26
+SUBJECT_TEXT=
27
+
28
+function show_help {
29
+    echo ''
30
+    echo 'freedombone-unignore -u [username] -e [mail address] -t [text in subject line]'
31
+    echo ''
32
+    exit 0
33
+}
34
+
35
+while [[ $# > 1 ]]
36
+do
37
+key="$1"
38
+
39
+case $key in
40
+    -h|--help)
41
+    show_help
42
+    ;;
43
+    -u|--user)
44
+    shift
45
+    MYUSERNAME="$1"
46
+    ;;
47
+    -e|--email)
48
+    shift
49
+    EMAIL_ADDRESS="$1"
50
+    ;;
51
+    -t|--text)
52
+    shift
53
+    SUBJECT_TEXT="$1"
54
+    ;;
55
+    *)
56
+    # unknown option
57
+    ;;
58
+esac
59
+shift
60
+done
61
+
62
+if ! [[ $MYUSERNAME && $EMAIL_ADDRESS ]]; then
63
+    if ! [[ $MYUSERNAME && $SUBJECT_TEXT ]]; then
64
+        show_help
65
+    fi
66
+fi
67
+
68
+MUTTRC=/home/$MYUSERNAME/.muttrc
69
+PM=/home/$MYUSERNAME/.procmailrc
70
+
71
+# unignore if subject line contains text
72
+if [ $SUBJECT_TEXT ]; then
73
+    if ! grep -q "Ignore rule for $SUBJECT_TEXT" $PM; then
74
+        sed -i "/# Ignore rule for $SUBJECT_TEXT/,/# End of ignore rule/d" $PM
75
+    fi
76
+fi
77
+
78
+# unignore an email address
79
+if [ $EMAIL_ADDRESS ]; then
80
+    if ! grep -q "Ignore rule for $EMAIL_ADDRESS" $PM; then
81
+        sed -i "/# Ignore rule for $EMAIL_ADDRESS/,/# End of ignore rule/d" $PM
82
+    fi
83
+fi
84
+
85
+exit 0