summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-09-06 00:43:13 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-09-06 00:43:13 -0400
commit29b29a629aa7f64d4aadd8eb2b9a4a3ca272523a (patch)
tree3044b70947d2c1faa0510b342cc81951dcf2ce9b
parentac4dcb64a8f6c07dfe50e9005dc4246f21ebf84e (diff)
add generating the postfix map
-rw-r--r--Makefile10
-rwxr-xr-xbin/postfix-show-virtual-map21
2 files changed, 30 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 3253c91..c407c71 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ FAIL = exit 1
dep_dir = $1 $(shell find $1)
users = $(call dep_dir,users)
-all: PHONY pacman-keyring
+all: PHONY pacman-keyring postfix-virtual-map
clean: PHONY
rm -rf output/cache
@@ -20,6 +20,14 @@ distclean: PHONY
####
+postfix-virtual-map: PHONY output/postfix-virtual-map/virtual-parabola.nu
+
+output/postfix-virtual-map/virtual-parabola.nu: ${users}
+ ${MKDIRS} ${@D}
+ bin/postfix-show-virtual-map > $@
+
+####
+
pacman-keyring: PHONY \
output/pacman-keyring/${KEYRING_NAME}.gpg \
output/pacman-keyring/${KEYRING_NAME}-trusted \
diff --git a/bin/postfix-show-virtual-map b/bin/postfix-show-virtual-map
new file mode 100755
index 0000000..1203c63
--- /dev/null
+++ b/bin/postfix-show-virtual-map
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+# Usage: postfix-show-virtual-map > ${file} && postmap hash:${file}
+cfg_groups = [ "hackers", "fellows" ]
+
+######################################################################
+require 'yaml'
+
+users = Dir.glob("users/*.yml").map{|f|YAML::load(open(f))}
+ .find_all{|u|u["groups"] and not (u["groups"] & cfg_groups).empty?}
+
+users.each do |user|
+ if user["email"] and user["email"].length > 0
+ if user["email"][0] =~ /.*@parabola.nu$/
+ if user["email"].length > 1
+ puts "#{user["username"]}@parabola.nu #{user["email"][1]}"
+ end
+ else
+ puts "#{user["username"]}@parabola.nu #{user["email"][0]}"
+ end
+ end
+end