diff --git a/.travis.yml b/.travis.yml index a690b21..6191048 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,12 @@ addons: before_install: - cp config/database.example.yml config/database.yml - - cp config/chexpire.test.yml config/chexpire.yml - cp config/secrets.example.yml config/secrets.yml + # Test configuration loaded from chexpire.defaults.yml, + # but chexpire.yml file is required + - touch config/chexpire.yml + install: - bundle install - yarn install diff --git a/Gemfile b/Gemfile index e3665cb..14530c2 100644 --- a/Gemfile +++ b/Gemfile @@ -38,6 +38,7 @@ gem 'bcrypt', '~> 3.1.7' gem 'open4' gem 'naught' +gem 'hashie' gem 'whenever', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 5e091d7..ff2fd77 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -134,6 +134,7 @@ GEM has_scope (0.7.2) actionpack (>= 4.1) activesupport (>= 4.1) + hashie (3.5.7) i18n (1.0.1) concurrent-ruby (~> 1.0) io-like (0.3.0) @@ -354,6 +355,7 @@ DEPENDENCIES guard guard-minitest has_scope + hashie jbuilder (~> 2.5) kaminari launchy diff --git a/INSTALL.md b/INSTALL.md index 7c6cf3d..afe5a26 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -45,11 +45,13 @@ To use elliptic curve SSH keys, we need to have `libsodium` and its headers. ## Rails configuration -After cloning this repository, you have to create and edit a few files from example files, for your local development configuration : +After cloning this repository, you have to create and edit a few files from example or defaults files, for your local development configuration : - `config/database.yml` -- `config/chexpire.yml` - `config/secrets.yml` +- `config/chexpire.yml` : set at least the `mailer_default_from` and `host` variables. See other configuration overridable in `config/chexpire.defaults.yml`. + +Theses files will be ignored by git. ## Database diff --git a/config/application.rb b/config/application.rb index 5adecf8..9f5c3df 100644 --- a/config/application.rb +++ b/config/application.rb @@ -32,6 +32,12 @@ module Chexpire config.time_zone = "Europe/Paris" - config.chexpire = config_for(:chexpire) + unless Rails.root.join("config", "chexpire.yml").readable? + fail "Missing Chexpire configuration file. + You have to create the config/chexpire.yml file and set at least the required values. + Look at config/chexpire.defaults.yml and INSTALL.md for more information" + end + + config.chexpire = Hashie::Mash.new(config_for(:"chexpire.defaults").deep_merge(config_for(:chexpire))) end end diff --git a/config/chexpire.defaults.yml b/config/chexpire.defaults.yml new file mode 100644 index 0000000..3080d0f --- /dev/null +++ b/config/chexpire.defaults.yml @@ -0,0 +1,53 @@ +# DO NOT EDIT THIS FILE +# +# If you want override a value for any environment, +# create a `config/chexpire.yml` file, +# write your overrided keys under your environment namespace. +# +# Some keys are required to be overidden for your environment. +# +# Example: +# +# production: +# mailer_default_from: "contact@yourdomain.org" +# host: mychexpire.instance.org + +default: &default + mailer_default_from: "from@example.org" # REQUIRED: Email will be sent with this address as From header + host: chexpire.local # REQUIRED: Host of the website. + + interface: + consecutive_failures_as_error: 2 # number of consecutive failures before display a check as "in error" (value for interface only) + notifier: + interval: 0.00 # pause in second between each notification sent + consecutive_failures: 4 # number of consecutive failures before sending a notification for recurrent failures + checks_domain: + interval: 0.5 # pause in second between each whois call + long_term_interval: 300 # when last known expiry date exceeds this interval in days, whois verification won't happen every day + long_term_frequency: 4 # when last known expiry exceeds $long_term, perform whois verification each $long_term_frequency days instead of every day + checks_ssl: + check_http_path: # defaults to check_http in $PATH + check_http_args: # array of arguments appended to defaults arguments (-C 0 -H $HOSTNAME). + +development: + <<: *default + host: "chexpire.local" + +production: + <<: *default + action_mailer_config: + delivery_method: :sendmail + +staging: + <<: *default + action_mailer_config: + delivery_method: :sendmail + +test: + <<: *default + mailer_default_from: "testcontact@example.org" + host: localhost + checks_dummy: + interval: 0.0 + long_term_interval: 60 + long_term_frequency: 10 diff --git a/config/chexpire.example.yml b/config/chexpire.example.yml deleted file mode 100644 index 324a5d7..0000000 --- a/config/chexpire.example.yml +++ /dev/null @@ -1,27 +0,0 @@ -default: &default - mailer_default_from: "from@example.org" - notifier: - interval: 0.00 - failure_days: 3 - checks_domain: - interval: 0.5 - long_term: 60 - long_term_frequency: 10 - checks_ssl: - check_http_path: # default to check_http in $PATH) - check_http_args: # array of arguments appended to defaults: -C 0 -H $HOSTNAME. - -development: - <<: *default - host: "chexpire.local" - -production: - action_mailer_config: - delivery_method: :sendmail - -staging: - action_mailer_config: - delivery_method: :sendmail - -# test configuration included in file used by CI services -<%= IO.read Rails.root.join("config", "chexpire.test.yml") %> diff --git a/config/chexpire.test.yml b/config/chexpire.test.yml deleted file mode 100644 index 6af09a8..0000000 --- a/config/chexpire.test.yml +++ /dev/null @@ -1,13 +0,0 @@ -test: - mailer_default_from: "contact@chexpire.org" - host: "localhost" - notifier: - interval: 0.00 - failure_days: 3 - checks_domain: - interval: 0.00 - long_term: 60 - long_term_frequency: 10 - checks_ssl: - check_http_path: - check_http_args: