From 15b35deec06efa6efc5e527fa2c277c581caf009 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Jun 2016 20:20:07 -0400 Subject: tidy systemd stuff --- scripts/common.rb.in | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/common.rb.in (limited to 'scripts/common.rb.in') diff --git a/scripts/common.rb.in b/scripts/common.rb.in new file mode 100644 index 0000000..c7dc261 --- /dev/null +++ b/scripts/common.rb.in @@ -0,0 +1,22 @@ +require 'yaml' + +def cfg + @cfg ||= YAML::load(open("@conf_file@")) +end + +def load_user_yaml(filename) + user = YAML::load(open(filename)) + groups = user["groups"] || [] + user["groups"] = groups.concat((groups & cfg["groupgroups"].keys).map{|g|cfg["groupgroups"][g]}.flatten) + return user +end + +def load_all_users + users = {} + Dir.glob("#{cfg["yamldir"]}/*.yml").map{|filename| + uid = File.basename(filename).sub(/^([0-9]*)\.yml$/, "\\1").to_i + user = load_user_yaml(filename) + users[uid] = user + } + return users +end -- cgit v1.2.3-54-g00ecf