From a8ecb502faf303c868c5d72329f392bf0aeea41e Mon Sep 17 00:00:00 2001 From: Adam Cooke Date: Wed, 19 Apr 2017 14:30:00 +0100 Subject: [PATCH] improve config file generation --- config/postal.development.yml | 77 ------------------------------- config/postal.example.yml | 29 ++++++------ script/generate_initial_config.rb | 5 +- 3 files changed, 17 insertions(+), 94 deletions(-) delete mode 100644 config/postal.development.yml diff --git a/config/postal.development.yml b/config/postal.development.yml deleted file mode 100644 index aa30c16..0000000 --- a/config/postal.development.yml +++ /dev/null @@ -1,77 +0,0 @@ -web: - host: localhost:5000 - protocol: http - fast_server_host: localhost:5010 - fast_server_protocol: http - -web_server: - bind_address: 0.0.0.0 - port: 5000 - max_threads: 5 - -fast_server: - bind_address: 0.0.0.0 - port: 5010 - ssl_port: 5011 - proxy_protocol: false - -general: - use_ip_pools: false - exception_url: xxx - -logging: - stdout: false - max_log_file_size: 20 - max_log_files: 10 - -main_db: - host: localhost - port: 3306 - username: root - password: - database: postal - -message_db: - host: localhost - port: 3306 - username: root - password: - prefix: postal - -rabbitmq: - host: localhost - port: 5672 - username: guest - password: guest - vhost: null - -smtp_server: - proxy_protocol: false - log_connect: true - evented: false - ports: - - 2525 - -dns: - spf_include: spf.example.com - dkim_identifier: postal - domain_verify_prefix: postal-verification - custom_return_path_prefix: psrp - return_path: amrp.example.com - smtp_server_hostname: smtp.example.com - route_domain: routes.example.com - track_domain: track.example.com - mx_records: - - mx1.example.com - - mx2.example.com - -smtp: - host: smtp.atech.io - -espect: - hosts: - - http://espect01.infra.atech.io - -rails: - environment: development - secret_key: 1bd1a4fe0cb3fb166be9b0e388beb36557b49ae5bed97ab3e300353de06d1fe55522b21596db8ed5d83c031ca58696340fb3d70f59eb0c096bbe4034fc12e4cd diff --git a/config/postal.example.yml b/config/postal.example.yml index 37e43b9..054f107 100644 --- a/config/postal.example.yml +++ b/config/postal.example.yml @@ -1,8 +1,6 @@ web: host: postal.example.com protocol: https - fast_server_host: postal-click.example.com - fast_server_protocol: https web_server: bind_address: 0.0.0.0 @@ -13,11 +11,11 @@ fast_server: bind_address: 0.0.0.0 port: 5010 ssl_port: 5011 - proxy_protocol: true + proxy_protocol: false general: - use_ip_pools: true - exception_url: xxx + use_ip_pools: false + exception_url: null logging: stdout: false @@ -48,23 +46,22 @@ rabbitmq: smtp_server: proxy_protocol: false log_connect: true - log_exclude_ips: null evented: true ports: - 2525 dns: - spf_include: spf.example.com - dkim_identifier: postal - domain_verify_prefix: postal-verification - custom_return_path_prefix: psrp - return_path: amrp.example.com - smtp_server_hostname: smtp.example.com - route_domain: routes.example.com - track_domain: track.example.com mx_records: - mx1.example.com - mx2.example.com + smtp_server_hostname: smtp.example.com + spf_include: spf.example.com + return_path: rp.example.com + route_domain: routes.example.com + track_domain: track.example.com + dkim_identifier: postal + domain_verify_prefix: postal-verification + custom_return_path_prefix: psrp smtp: host: smtp.blah @@ -74,6 +71,6 @@ espect: - http://espect01.infra.atech.io rails: - environment: development - secret_key: 1bd1a4fe0cb3fb166be9b0e388beb36557b49ae5bed97ab3e300353de06d1fe55522b21596db8ed5d83c031ca58696340fb3d70f59eb0c096bbe4034fc12e4cd + environment: production + secret_key: {{secretkey}} diff --git a/script/generate_initial_config.rb b/script/generate_initial_config.rb index 37923bb..73a6be6 100755 --- a/script/generate_initial_config.rb +++ b/script/generate_initial_config.rb @@ -1,9 +1,12 @@ #!/usr/bin/env ruby require File.expand_path('../../lib/postal/config', __FILE__) require 'openssl' +require 'securerandom' unless File.exist?(Postal.config_file_path) - FileUtils.cp(config_root('postal.example.yml'), Postal.config_file_path) + content = File.read(Postal.config_root.join('postal.example.yml')) + content.gsub!('{{secretkey}}', SecureRandom.hex(128)) + File.open(Postal.config_file_path, 'w') { |f| f.write(content) } puts "Created example config file at #{Postal.config_file_path}" end