From d40d1e4aa60c059ae916c4c83cb655dd62e9768f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 11 Feb 2016 09:45:05 +0000 Subject: [PATCH] Insert rule after previous rules --- src/freedombone-addlist | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/freedombone-addlist b/src/freedombone-addlist index 7745adeb..1eb5d1ac 100755 --- a/src/freedombone-addlist +++ b/src/freedombone-addlist @@ -98,12 +98,24 @@ if [ ! -d "$LISTDIR" ]; then fi chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR + if ! grep -q "Subject:.*()\[$SUBJECTTAG\]" $PM; then - echo "" >> $PM - echo ":0" >> $PM - echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM - echo "$LISTDIR/new" >> $PM - chown $MYUSERNAME:$MYUSERNAME $PM + if ! grep -q "End of rule" $PM; then + echo "" >> $PM + echo "/# Email rule for $MAILINGLIST subject \[$SUBJECTTAG\]" >> $PM + echo ":0" >> $PM + echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM + echo "$LISTDIR/new" >> $PM + echo "/# End of rule" >> $PM + chown $MYUSERNAME:$MYUSERNAME $PM + else + sed -i "/End of rule/a +/# Email rule for $MAILINGLIST subject \[$SUBJECTTAG\] +:0 + * ^Subject:.*()\[$SUBJECTTAG\] +$LISTDIR/new +/# End of rule" $PM + fi fi if [ ! -f "$MUTTRC" ]; then