summaryrefslogtreecommitdiffstats
path: root/makelist.sh
diff options
context:
space:
mode:
Diffstat (limited to 'makelist.sh')
-rwxr-xr-xmakelist.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/makelist.sh b/makelist.sh
new file mode 100755
index 0000000..a1f1566
--- /dev/null
+++ b/makelist.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+usage() {
+ echo "usage: ./makelist.sh <name> <address> <owner>"
+ echo ""
+ echo "<name> is the list name, this should be a value suitable for a"
+ echo "directory name, however '@', '.', and ' ' characters are not allowed."
+ echo "<address> is the list post address, should be a valid email address."
+ echo "<owner> is the primary point of contact for the list, should be a"
+ echo "valid email address."
+ echo ""
+ echo "This script must be run from the top-level directory and may fail"
+ echo "otherwise. This script will also fail if the requested list name"
+ echo "already exists."
+ echo ""
+ echo "On success, mailing list config files are written to:"
+ echo "userconfig/lists/<name>"
+ exit 1
+}
+
+echo "$1" | grep -Eq '^[^/@. ]+$' || usage
+echo "$2" | grep -Eq '^[^ ]+@[^ ]+$' || usage
+echo "$3" | grep -Eq '^[^ ]+@[^ ]+$' || usage
+
+listdir="userconfig/lists/$1"
+unsub=$(echo "$2" | sed 's/@/+unsubscribe@/g')
+
+[ -d userconfig/lists ] || usage
+[ -d "$listdir" ] && usage
+mkdir "$listdir"
+
+# Default mlmmj list tunables
+echo "$2" >"$listdir/listaddress"
+echo "$3" >"$listdir/owner"
+echo "$3" >"$listdir/moderators"
+echo "X-Mailing-List: $2" >>"$listdir/customheaders"
+echo "List-Unsubscribe: <mailto:$unsub>" >>"$listdir/customheaders"
+touch "$listdir/notifysub"
+touch "$listdir/noget"
+touch "$listdir/nonomailsub"