aboutsummaryrefslogtreecommitdiff
path: root/files/.mutt/gen_maillist.sh
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2011-10-17 11:54:08 +0600
committerAnton Bobov <abobov@gmail.com>2011-10-17 11:56:00 +0600
commitb63ddd9406eabce7887ae13057732c9672b3fd75 (patch)
treeeaaec064bfdd4902327965bd34729b6d257077f1 /files/.mutt/gen_maillist.sh
parentdcd755f2e5243cc0f7ef3d004309bae3ab5dd545 (diff)
f
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}"