From 87c9c583caca33112f88622eed8849e98bdf3a26 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 8 Apr 2012 20:59:51 -0400 Subject: [PATCH] Load the default configuration file in lib/mailshears.rb. Allow the user to load his own configuration file, overriding the defaults. --- bin/mailshears | 3 --- bin/configuration.rb => lib/default_configuration.rb | 0 lib/mailshears.rb | 12 ++++++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) rename bin/configuration.rb => lib/default_configuration.rb (100%) diff --git a/bin/mailshears b/bin/mailshears index 96a3c30..01dcb30 100755 --- a/bin/mailshears +++ b/bin/mailshears @@ -15,9 +15,6 @@ require 'mailshears' -# Load our config file. -require 'configuration' - pgadb = PostfixadminDb.new(Configuration::DBHOST, Configuration::DBPORT, Configuration::DBOPTS, diff --git a/bin/configuration.rb b/lib/default_configuration.rb similarity index 100% rename from bin/configuration.rb rename to lib/default_configuration.rb diff --git a/lib/mailshears.rb b/lib/mailshears.rb index 75e38f0..30dd71e 100644 --- a/lib/mailshears.rb +++ b/lib/mailshears.rb @@ -5,6 +5,18 @@ require 'mailshears/errors.rb' require 'mailshears/exit_codes.rb' require 'mailshears/postfixadmin_db' +# Load the default config file first, and let the user override it. +require 'default_configuration' + +begin + # Try to load the user's configuration file. + userconf_path = ENV['HOME'] + '/.mailshears.conf' + require userconf_path +rescue + puts 'No user configuration file (~/.mailshears.conf) found.' + puts 'Continuing...' +end + Configuration::PLUGINS.each do |plugin_file| require "mailshears/plugins/#{plugin_file}" end -- 2.44.2