From 3ed4226045969b1f7c6315affc871b13f013ecf4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 11 Feb 2016 15:15:34 +0000 Subject: [PATCH] Create mailing list from address only --- src/freedombone-addlist | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/freedombone-addlist b/src/freedombone-addlist index 592760d9..3a909d66 100755 --- a/src/freedombone-addlist +++ b/src/freedombone-addlist @@ -82,7 +82,10 @@ esac shift done -if ! [[ $MYUSERNAME && $MAILINGLIST && $SUBJECTTAG ]]; then +if ! [[ $MYUSERNAME ]]; then + show_help +fi +if [ ! $MAILINGLIST && ! $SUBJECTTAG ]; then show_help fi @@ -104,20 +107,11 @@ fi chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR -if ! grep -q "Subject:.*()\[$SUBJECTTAG\]" $PM; then - if [[ $PUBLIC != "yes" ]]; then - # private emails go after the encryption stage - filter=" -# Email rule for $MAILINGLIST subject [$SUBJECTTAG] -:0 - * ^Subject:.*()\[$SUBJECTTAG\] -$LISTDIR/new -# End of rule -" - echo "$filter" >> $PM - else - # public emails are copied before hte encryption stage - if ! grep -q '# encrypt' $PM; then +if [ ${#SUBJECTTAG} -gt 0 ]; then + # use the subject tag + if ! grep -q "Subject:.*()\[$SUBJECTTAG\]" $PM; then + if [[ $PUBLIC != "yes" ]]; then + # private emails go after the encryption stage filter=" # Email rule for $MAILINGLIST subject [$SUBJECTTAG] :0 @@ -127,11 +121,25 @@ $LISTDIR/new " echo "$filter" >> $PM else - filter=$(echo "# Email rule for $MAILINGLIST subject [$SUBJECTTAG]\n:0\n * ^Subject:.*()\\\[$SUBJECTTAG\\\]\n$LISTDIR/new\n# End of rule\n") - sed -i "/# encrypt/i ${filter}" $PM + # public emails are copied before hte encryption stage + if ! grep -q '# encrypt' $PM; then + filter=" +# Email rule for $MAILINGLIST subject [$SUBJECTTAG] +:0 + * ^Subject:.*()\[$SUBJECTTAG\] +$LISTDIR/new +# End of rule +" + echo "$filter" >> $PM + else + filter=$(echo "# Email rule for $MAILINGLIST subject [$SUBJECTTAG]\n:0\n * ^Subject:.*()\\\[$SUBJECTTAG\\\]\n$LISTDIR/new\n# End of rule\n") + sed -i "/# encrypt/i ${filter}" $PM + fi fi + chown $MYUSERNAME:$MYUSERNAME $PM fi - chown $MYUSERNAME:$MYUSERNAME $PM +else + exit ${PROJECT_NAME}-addemail -u $MYUSERNAME -e $LIST_ADDRESS -g $MAILINGLIST --public $PUBLIC fi if [ ! -f "$MUTTRC" ]; then