]> gitweb.michael.orlitzky.com - mailshears.git/commitdiff
Load the default configuration file in lib/mailshears.rb.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 9 Apr 2012 00:59:51 +0000 (20:59 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 9 Apr 2012 00:59:51 +0000 (20:59 -0400)
Allow the user to load his own configuration file, overriding the defaults.

bin/mailshears
lib/default_configuration.rb [moved from bin/configuration.rb with 100% similarity]
lib/mailshears.rb

index 96a3c303777269d9a1a32c8110f6821478fbae15..01dcb30f2a2fc2d73d22f36f2f4b43ed92800f42 100755 (executable)
@@ -15,9 +15,6 @@
 
 require 'mailshears'
 
-# Load our config file.
-require 'configuration'
-
 pgadb = PostfixadminDb.new(Configuration::DBHOST,
                            Configuration::DBPORT,
                            Configuration::DBOPTS,
index 75e38f0927df7c32df1099805b34a23b0820d430..30dd71ebc99130aeb0c128a7433fee5d244b57da 100644 (file)
@@ -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