aboutsummaryrefslogtreecommitdiff
path: root/files/.mutt/gen_maillist.sh
diff options
context:
space:
mode:
Diffstat (limited to 'files/.mutt/gen_maillist.sh')
-rwxr-xr-xfiles/.mutt/gen_maillist.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/files/.mutt/gen_maillist.sh b/files/.mutt/gen_maillist.sh
new file mode 100755
index 0000000..89e13c7
--- /dev/null
+++ b/files/.mutt/gen_maillist.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+CONFIG=$(dirname $0)/maillists
+RESULT=maillists.generate
+FOLDER_HOOK=folder-hooks.maillist
+
+die() {
+ echo $1
+ exit 1
+}
+
+add_maillist() {
+ email=$1
+ mailbox=$2
+
+ echo "# email: $email"
+ echo "# mailbox: $mailbox"
+
+ # Subscription
+ echo "subscribe $email"
+ # Mailboxes
+ echo "mailboxes \"$mailbox\""
+ # Folder hook
+ echo "folder-hook \"$mailbox\" source $FOLDER_HOOK"
+ # FCC hook
+ echo "fcc-hook $email \"$mailbox\""
+
+ printf "\n\n"
+}
+
+test -f "$CONFIG" || die "Config file ($RESULT) not exists."
+
+echo "# Generate date: $(date)" > "$RESULT" || die "Can't write file ($RESULT)."
+echo "# vim: ft=muttrc :" >> "$RESULT"
+
+while read email mailbox
+do
+ if [[ -n "$email" ]]
+ then
+ if [[ "$(echo $email | sed 's/^\s*#//')" == "$email" ]]
+ then
+ add_maillist $email $mailbox >> "$RESULT"
+ fi
+ fi
+done < "${CONFIG}"