From 29b29a629aa7f64d4aadd8eb2b9a4a3ca272523a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 6 Sep 2014 00:43:13 -0400 Subject: add generating the postfix map --- Makefile | 10 +++++++++- bin/postfix-show-virtual-map | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 bin/postfix-show-virtual-map 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 -- cgit v1.1-4-g5e80