Allow more than one rule per mailing list

This commit is contained in:
Bob Mottram 2016-02-12 09:21:56 +00:00
parent 42ad541773
commit df00b7e374
1 changed files with 7 additions and 5 deletions

View File

@ -82,9 +82,10 @@ esac
shift shift
done done
if ! [[ $MYUSERNAME ]]; then if [ ! $MYUSERNAME ]; then
show_help show_help
fi fi
if [[ ! $MAILINGLIST && ! $SUBJECTTAG ]]; then if [[ ! $MAILINGLIST && ! $SUBJECTTAG ]]; then
show_help show_help
fi fi
@ -93,9 +94,8 @@ MUTTRC=/home/$MYUSERNAME/.muttrc
PM=/home/$MYUSERNAME/.procmailrc PM=/home/$MYUSERNAME/.procmailrc
LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST LISTDIR=/home/$MYUSERNAME/Maildir/$MAILINGLIST
# Exit if the list was already added
if grep -q "=$MAILINGLIST" $MUTTRC; then if grep -q "=$MAILINGLIST" $MUTTRC; then
exit 54678 echo $"Mailing list $MAILINGLIST was already added"
fi fi
if [ ! -d "$LISTDIR" ]; then if [ ! -d "$LISTDIR" ]; then
@ -155,9 +155,11 @@ fi
MUTT_MAILBOXES=$(grep "mailboxes =" $MUTTRC) MUTT_MAILBOXES=$(grep "mailboxes =" $MUTTRC)
if [[ $MUTT_MAILBOXES != *$MAILINGLIST* ]]; then if [[ $MUTT_MAILBOXES != *$MAILINGLIST* ]]; then
if ! grep -q "=$MAILINGLIST" $MUTTRC; then
sed -i "s|$MUTT_MAILBOXES|$MUTT_MAILBOXES =$MAILINGLIST|g" $MUTTRC sed -i "s|$MUTT_MAILBOXES|$MUTT_MAILBOXES =$MAILINGLIST|g" $MUTTRC
chown $MYUSERNAME:$MYUSERNAME $MUTTRC chown $MYUSERNAME:$MYUSERNAME $MUTTRC
fi fi
fi
if [ $LIST_ADDRESS ]; then if [ $LIST_ADDRESS ]; then
sed -i "s|unsubscribe $LIST_ADDRESS|subscribe $LIST_ADDRESS|g" $MUTTRC sed -i "s|unsubscribe $LIST_ADDRESS|subscribe $LIST_ADDRESS|g" $MUTTRC