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