From: Michael Orlitzky Date: Mon, 9 Apr 2012 00:59:51 +0000 (-0400) Subject: Load the default configuration file in lib/mailshears.rb. X-Git-Tag: 0.0.1~117 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=87c9c583caca33112f88622eed8849e98bdf3a26;p=mailshears.git Load the default configuration file in lib/mailshears.rb. Allow the user to load his own configuration file, overriding the defaults. --- 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