X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6d73acc845a2dd7413fdde0742473d83bf3d0719..412c3d66297962c8b2b0385ec0fa14d470dfdb03:/docker/build_tools/config.rb diff --git a/docker/build_tools/config.rb b/docker/build_tools/config.rb index ddf923736e..77c721c61f 100755 --- a/docker/build_tools/config.rb +++ b/docker/build_tools/config.rb @@ -2,6 +2,7 @@ require 'yaml' require 'fileutils' +require 'digest' abort 'Error: Ruby >= 1.9.3 required.' if RUBY_VERSION < '1.9.3' @@ -13,10 +14,13 @@ config = YAML.load_file('config.yml') # be suitable for any installation. # Any _PW/_SECRET config settings represent passwords/secrets. If they -# are blank, choose a password randomly. -config.each_key do |var| +# are blank, choose a password. Make sure the generated password +# doesn't change if config.yml doesn't change. Otherwise, keys won't +# match any more if (say) keep's files get regenerated but apiserver's +# don't. +config.sort.map do |var,val| if (var.end_with?('_PW') || var.end_with?('_SECRET')) && (config[var].nil? || config[var].empty?) - config[var] = rand(2**256).to_s(36) + config[var] = Digest::SHA1.hexdigest(`hostname` + var + config.to_yaml) end end @@ -30,12 +34,18 @@ end # the same tree structure as in the original source. Then all # the files can be added to the docker container with a single ADD. -Dir.glob('*/generated/*') do |stale_file| +if ARGV[0] and ARGV[0].length > 0 + globdir = ARGV[0] +else + globdir = '*' +end + +Dir.glob(globdir + '/generated/*') do |stale_file| File.delete(stale_file) end File.umask(022) -Dir.glob('*/*.in') do |template_file| +Dir.glob(globdir + '/*.in') do |template_file| generated_dir = File.join(File.dirname(template_file), 'generated') Dir.mkdir(generated_dir) unless Dir.exists? generated_dir output_path = File.join(generated_dir, File.basename(template_file, '.in'))