Separate the add and remove operations on lists

This commit is contained in:
Timothée Floure 2018-10-07 22:15:19 +02:00
parent 165e01269d
commit 1c8eb14154
2 changed files with 24 additions and 18 deletions

View File

@ -1,5 +1,6 @@
domain = "unipoly.ch"
lists = [ "membres"]
lists_add = ["membres"]
lists_remove = ["membres"]
[ldap]
host = "ldap.gnugen.ch"

View File

@ -40,7 +40,8 @@ def main
domain = conf["domain"]
basetree = conf["ldap"]["lists"]["basetree"]
conf["lists"].each do |cn|
lists = (conf["lists_add"] + conf["lists_remove"]).uniq
lists.each do |cn|
puts ">> Processing list #{cn}@#{domain}"
filter = Net::LDAP::Filter.eq("cn", cn)
@ -75,6 +76,7 @@ def main
if (subscribers.include?(m))
subscribers.delete(m)
else
if (conf["lists_add"].include?(cn))
print "Adding #{m}... "
mlmmj_sub_binary = conf["mlmmj"]["sub_binary"]
%x(#{mlmmj_sub_binary} -L #{list} -a #{m} -q -f -s)
@ -85,8 +87,10 @@ def main
end
end
end
end
# Remove remaining "subcribers" (= they did not match with members)
if (conf["lists_remove"].include?(cn))
subscribers.each do |s|
print "Removing #{s}... "
mlmmj_unsub_binary = conf["mlmmj"]["unsub_binary"]
@ -97,6 +101,7 @@ def main
puts "Failed"
end
end
end
print "\n"
else
puts "FAIL"