X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e02fdd5490c3fcf24281f0fedc6ad4a0a12577c4..df63e3facb4e13ff47a7437c0dd23190cf530a7a:/docker/config.rb diff --git a/docker/config.rb b/docker/config.rb index c96819e506..793a6ff35d 100755 --- a/docker/config.rb +++ b/docker/config.rb @@ -17,11 +17,12 @@ config['OMNIAUTH_APP_SECRET'] = rand(2**512).to_s(36) # The secret token in services/api/config/initializers/secret_token.rb. config['API_SECRET'] = rand(2**256).to_s(36) +config['WORKER_SECRET'] = rand(2**256).to_s(36) # Any _PW config settings represent a database password. If it # is blank, choose a password randomly. config.each_key do |var| - if var.end_with?('_PW') and (config[var].nil? or config[var].empty?) + if var.end_with?('_PW') && (config[var].nil? || config[var].empty?) config[var] = rand(2**256).to_s(36) end end @@ -30,9 +31,20 @@ end # For each *.in file in the docker directories, substitute any # @@variables@@ found in the file with the appropriate config # variable. Support up to 10 levels of nesting. +# +# TODO(twp): add the *.in files directory to the source tree, and +# when expanding them, add them to the "generated" directory with +# 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| + File.delete(stale_file) +end Dir.glob('*/*.in') do |template_file| - output_path = template_file.sub(/\.in$/, '') + 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')) output = File.open(output_path, "w") File.open(template_file) do |input| input.each_line do |line| @@ -40,7 +52,11 @@ Dir.glob('*/*.in') do |template_file| @count = 0 while @count < 10 @out = line.gsub!(/@@(.*?)@@/) do |var| - config[Regexp.last_match[1]] || var.gsub!(/@@/, '@_NOT_FOUND_@') + if config.key?(Regexp.last_match[1]) + config[Regexp.last_match[1]] + else + var.gsub!(/@@/, '@_NOT_FOUND_@') + end end break if @out.nil? @count += 1