Insert rule after previous rules

This commit is contained in:
Bob Mottram 2016-02-11 09:45:05 +00:00
parent fb94a7c28e
commit d40d1e4aa6
1 changed files with 17 additions and 5 deletions

View File

@ -98,12 +98,24 @@ if [ ! -d "$LISTDIR" ]; then
fi fi
chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
if ! grep -q "Subject:.*()\[$SUBJECTTAG\]" $PM; then if ! grep -q "Subject:.*()\[$SUBJECTTAG\]" $PM; then
echo "" >> $PM if ! grep -q "End of rule" $PM; then
echo ":0" >> $PM echo "" >> $PM
echo " * ^Subject:.*()\[$SUBJECTTAG\]" >> $PM echo "/# Email rule for $MAILINGLIST subject \[$SUBJECTTAG\]" >> $PM
echo "$LISTDIR/new" >> $PM echo ":0" >> $PM
chown $MYUSERNAME:$MYUSERNAME $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 fi
if [ ! -f "$MUTTRC" ]; then if [ ! -f "$MUTTRC" ]; then