diff --git a/Makefile b/Makefile index 7d8d2d03..70ee2590 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ install: install -m 755 src/${APP}-addemail ${DESTDIR}${PREFIX}/bin install -m 755 src/${APP}-renew-cert ${DESTDIR}${PREFIX}/bin install -m 755 src/${APP}-rmlist ${DESTDIR}${PREFIX}/bin + install -m 755 src/${APP}-rmemail ${DESTDIR}${PREFIX}/bin mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/${APP}-prep.1.gz ${DESTDIR}${PREFIX}/share/man/man1 @@ -33,6 +34,7 @@ install: install -m 644 man/${APP}-addemail.1.gz ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/${APP}-renew-cert.1.gz ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/${APP}-rmlist.1.gz ${DESTDIR}${PREFIX}/share/man/man1 + install -m 644 man/${APP}-rmemail.1.gz ${DESTDIR}${PREFIX}/share/man/man1 uninstall: rm -f ${PREFIX}/share/man/man1/${APP}.1.gz rm -f ${PREFIX}/share/man/man1/${APP}-prep.1.gz @@ -45,6 +47,7 @@ uninstall: rm -f ${PREFIX}/share/man/man1/${APP}-addemail.1.gz rm -f ${PREFIX}/share/man/man1/${APP}-renew-cert.1.gz rm -f ${PREFIX}/share/man/man1/${APP}-rmlist.1.gz + rm -f ${PREFIX}/share/man/man1/${APP}-rmemail.1.gz rm -rf ${PREFIX}/share/${APP} rm -f ${PREFIX}/bin/${APP} rm -f ${PREFIX}/bin/${APP}-prep diff --git a/debian/source/include-binaries b/debian/source/include-binaries index 338df424..765eac7b 100644 --- a/debian/source/include-binaries +++ b/debian/source/include-binaries @@ -9,3 +9,4 @@ man/freedombone-addlist.1.gz man/freedombone-addemail.1.gz man/freedombone-renew-cert.1.gz man/freedombone-rmlist.1.gz +man/freedombone-rmemail.1.gz diff --git a/src/freedombone-addemail b/src/freedombone-addemail index e11bb754..f91ceee9 100755 --- a/src/freedombone-addemail +++ b/src/freedombone-addemail @@ -79,6 +79,7 @@ if ! grep -q "From: $EMAILADDRESS" $PM; then echo ":0" >> $PM echo " * ^From: $EMAILADDRESS" >> $PM echo "$LISTDIR/new" >> $PM + echo "# End of rule" >> $PM chown $MYUSERNAME:$MYUSERNAME $PM fi if [ ! -f "$MUTTRC" ]; then diff --git a/src/freedombone-rmemail b/src/freedombone-rmemail new file mode 100755 index 00000000..a3c50396 --- /dev/null +++ b/src/freedombone-rmemail @@ -0,0 +1,67 @@ +#!/bin/bash + +# Removes an email address rule from the email configuration + +# License +# ======= +# +# Copyright (C) 2015 Bob Mottram +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +MYUSERNAME=$USER +MAILINGLIST= + +function show_help { + echo '' + echo 'freedombone-rmemail -u [username] -e [email address]' + echo '' + exit 0 +} + +while [[ $# > 1 ]] +do +key="$1" + +case $key in + -h|--help) + show_help + ;; + -u|--user) + shift + MYUSERNAME="$1" + ;; + -e|--email) + shift + EMAILADDRESS="$1" + ;; + *) + # unknown option + ;; +esac +shift +done + +if ! [[ $MYUSERNAME && $EMAILADDRESS ]]; then + show_help +fi + +MUTTRC=/home/$MYUSERNAME/.muttrc +PM=/home/$MYUSERNAME/.procmailrc + +if grep -q "Email rule for $EMAILADDRESS ->" $PM; then + sed -i "/# Email rule for $EMAILADDRESS ->.*/,/# End of rule/d" $PM +fi + +exit 0