Project

General

Profile

« Previous | Next » 

Revision 74f1db3a

Added by Marc Dequènes about 15 years ago

  • ID 74f1db3a130a3149a98d54f2eeb625276f47a4ad

[evol] improve config #7 (move shadow loading in the Controller)

View differences:

bin/shadowwalker
set_locale(locale)
config_str = IO.read(File.join(LdapShadows::Config::CFG_DIR, "shadow.conf"))
config = YAML.load(config_str)
config_str_prv_filelist = [
File.join(ENV['HOME'], ".shadowwalker"),
File.join(LdapShadows::Config::CFG_DIR, "shadow_private.conf")
]
config_str_prv_filelist.each do |file|
if File.exists?(file)
config_str_prv = IO.read(file)
config.merge!(YAML.load(config_str_prv))
break
end
end
config.recursive_symbolize_keys!
$program_options = {}
......
cmdparser.add_command(CmdParse::VersionCommand.new)
def load_config_components(type)
c_config_dir = File.join(LdapShadows::Config::CFG_DIR, type)
c_config_pattern = File.join(c_config_dir, "**", "*.conf")
Dir.glob(c_config_pattern).each do |f|
next if f[0..0] == "."
c_name = File.basename(f).sub(".conf", "").to_sym
c_config = YAML.load(IO.read(f))
c_config.recursive_symbolize_keys!
yield(c_name, c_config)
end
end
$ldapctl = Controller.new
$ldapctl.set_global_config(config[:presentation])
load_config_components("aspects") do |c_name, c_config|
$ldapctl.set_aspect(c_name, c_config)
end
begin
ActiveLdap::Base.setup_connection(config[:ldap])
load_config_components("objects") do |c_name, c_config|
$ldapctl.load_object(c_name, c_config)
end
$ldapctl.load_relations
$ldapctl.load_shadow()
rescue ActiveLdap::Error => e
STDERR.puts _("LDAP connection error: %s") % e.to_s
exit 2
rescue
STDERR.puts _("Cannot load shadow configuration")
exit 2
end

Also available in: Unified diff