5 # Initialize config settings from config.yml
6 config = YAML.load_file('config.yml')
8 # ============================================================
9 # Add dynamically chosen config settings. These settings should
10 # be suitable for any installation.
12 # The APP_SECRET the application uses (with OMNIAUTH_APP_ID) to
13 # authenticate itself to Omniauth. By default this is generated
14 # randomly when the application is built; you can instead
15 # substitute a hardcoded string.
16 config['OMNIAUTH_APP_SECRET'] = rand(2**512).to_s(36)
18 # The secret token in services/api/config/initializers/secret_token.rb.
19 config['API_SECRET'] = rand(2**256).to_s(36)
21 # Any _PW config settings represent a database password. If it
22 # is blank, choose a password randomly.
23 config.each_key do |var|
24 if var.end_with?('_PW') and (config[var].nil? or config[var].empty?)
25 config[var] = rand(2**256).to_s(36)
29 # ============================================================
30 # For each *.in file in the docker directories, substitute any
31 # @@variables@@ found in the file with the appropriate config
32 # variable. Support up to 10 levels of nesting.
34 Dir.glob('*/*.in') do |template_file|
35 output_path = template_file.sub(/\.in$/, '')
36 output = File.open(output_path, "w")
37 File.open(template_file) do |input|
38 input.each_line do |line|
42 @out = line.gsub!(/@@(.*?)@@/) do |var|
43 config[Regexp.last_match[1]] || var.gsub!(/@@/, '@_NOT_FOUND_@')