summaryrefslogtreecommitdiff
path: root/bin/postfix-generate-virtual-map
blob: 1203c63ec4843662ff2c130ca4b702d730d17644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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