Command to remove email address rules

This commit is contained in:
Bob Mottram 2015-04-03 23:59:08 +01:00
parent 3775297ae5
commit 8103d453c6
4 changed files with 72 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

67
src/freedombone-rmemail Executable file
View File

@ -0,0 +1,67 @@
#!/bin/bash
# Removes an email address rule from the email configuration
# License
# =======
#
# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
#
# 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 <http://www.gnu.org/licenses/>.
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