Selaa lähdekoodia

Create mailing list from address only

Bob Mottram 9 vuotta sitten
vanhempi
commit
3ed4226045
1 muutettua tiedostoa jossa 23 lisäystä ja 15 poistoa
  1. 23
    15
      src/freedombone-addlist

+ 23
- 15
src/freedombone-addlist Näytä tiedosto

@@ -82,7 +82,10 @@ esac
82 82
 shift
83 83
 done
84 84
 
85
-if ! [[ $MYUSERNAME && $MAILINGLIST && $SUBJECTTAG ]]; then
85
+if ! [[ $MYUSERNAME ]]; then
86
+    show_help
87
+fi
88
+if [ ! $MAILINGLIST && ! $SUBJECTTAG ]; then
86 89
     show_help
87 90
 fi
88 91
 
@@ -104,34 +107,39 @@ fi
104 107
 
105 108
 chown -R $MYUSERNAME:$MYUSERNAME $LISTDIR
106 109
 
107
-if ! grep -q "Subject:.*()\[$SUBJECTTAG\]" $PM; then
108
-    if [[ $PUBLIC != "yes" ]]; then
109
-        # private emails go after the encryption stage
110
-        filter="
110
+if [ ${#SUBJECTTAG} -gt 0 ]; then
111
+    # use the subject tag
112
+    if ! grep -q "Subject:.*()\[$SUBJECTTAG\]" $PM; then
113
+        if [[ $PUBLIC != "yes" ]]; then
114
+            # private emails go after the encryption stage
115
+            filter="
111 116
 # Email rule for $MAILINGLIST subject [$SUBJECTTAG]
112 117
 :0
113 118
   * ^Subject:.*()\[$SUBJECTTAG\]
114 119
 $LISTDIR/new
115 120
 # End of rule
116 121
 "
117
-        echo "$filter" >> $PM
118
-    else
119
-        # public emails are copied before hte encryption stage
120
-        if ! grep -q '# encrypt' $PM; then
121
-            filter="
122
+            echo "$filter" >> $PM
123
+        else
124
+            # public emails are copied before hte encryption stage
125
+            if ! grep -q '# encrypt' $PM; then
126
+                filter="
122 127
 # Email rule for $MAILINGLIST subject [$SUBJECTTAG]
123 128
 :0
124 129
   * ^Subject:.*()\[$SUBJECTTAG\]
125 130
 $LISTDIR/new
126 131
 # End of rule
127 132
 "
128
-            echo "$filter" >> $PM
129
-        else
130
-            filter=$(echo "# Email rule for $MAILINGLIST subject [$SUBJECTTAG]\n:0\n  * ^Subject:.*()\\\[$SUBJECTTAG\\\]\n$LISTDIR/new\n# End of rule\n")
131
-            sed -i "/# encrypt/i ${filter}" $PM
133
+                echo "$filter" >> $PM
134
+            else
135
+                filter=$(echo "# Email rule for $MAILINGLIST subject [$SUBJECTTAG]\n:0\n  * ^Subject:.*()\\\[$SUBJECTTAG\\\]\n$LISTDIR/new\n# End of rule\n")
136
+                sed -i "/# encrypt/i ${filter}" $PM
137
+            fi
132 138
         fi
139
+        chown $MYUSERNAME:$MYUSERNAME $PM
133 140
     fi
134
-    chown $MYUSERNAME:$MYUSERNAME $PM
141
+else
142
+    exit ${PROJECT_NAME}-addemail -u $MYUSERNAME -e $LIST_ADDRESS -g $MAILINGLIST --public $PUBLIC
135 143
 fi
136 144
 
137 145
 if [ ! -f "$MUTTRC" ]; then