Change the local config path from $HOME/.mailshears.conf to $HOME/.mailshears.conf.rb so that Ruby will actually load it.
You put it in a directory somewhere, and run bin/mailshears. To make
it do anything, you'll need to create a config file. The default is
stored in lib/default_configuration.rb; I suggest you copy that to
-$HOME/.mailshears.conf and edit it to fit your environment.
+$HOME/.mailshears.conf.rb and edit it to fit your environment.
You'll probably want to set up a cron job to run it every once in a
while.
require 'mailshears'
-pgadb = PostfixadminDb.new(Configuration::DBHOST,
- Configuration::DBPORT,
- Configuration::DBOPTS,
- Configuration::DBTTY,
- Configuration::DBNAME,
- Configuration::DBUSER,
- Configuration::DBPASS)
+pgadb = PostfixadminDb.new(Configuration::dbhost,
+ Configuration::dbport,
+ Configuration::dbopts,
+ Configuration::dbtty,
+ Configuration::dbname,
+ Configuration::dbuser,
+ Configuration::dbpass)
begin
puts "Found: #{account} (#{plugin.describe_account(account)})"
end
- if Configuration::I_MEAN_BUSINESS
+ if Configuration::i_mean_business
# We have to delete the accounts before the domain,
# otherwise they'd already be gone.
leftover_accounts.each do |account|
module Configuration
# Really delete domains/accounts, or just find them? This parameter
- # could also be called, "I_TRUST_MAILSHEARS_NOT_TO_DO_ANYTHING_BAD".
- I_MEAN_BUSINESS = false
+ # could also be called, "i_trust_mailshears_not_to_do_anything_bad".
+ i_mean_business = false
# How to connect to your user/domain database. At the moment, this
# is PostfixAdmin.
#
# These should be obvious except for the ones that aren't. You can
# identify the non-obvious ones by my having left them blank.
- DBHOST = 'localhost'
- DBPORT = 5432
- DBOPTS = ''
- DBTTY = ''
- DBUSER = 'postgres'
- DBPASS = ''
- DBNAME = 'postfix'
+ dbhost = 'localhost'
+ dbport = 5432
+ dbopts = ''
+ dbtty = ''
+ dbuser = 'postgres'
+ dbpass = ''
+ dbname = 'postfix'
# This defines which plugins we'll use. The rest of the
# configuration is plugin-specific.
- PLUGINS = ['dovecot_mailstore', 'roundcube_db']
+ plugins = ['dovecot_mailstore', 'roundcube_db']
# Where your mailboxes are stored. The exact format could
# theoretically change in the future, but for now, the
# DovecotMailstore class is going to assume that the mailboxes are
# stored beneath this directory in <domain>/<username> format.
- MAIL_ROOT = '/var/spool/mail/vhosts'
+ mail_root = '/var/spool/mail/vhosts'
# Roundcube-specific configuration.
- ROUNDCUBE_DBHOST = 'localhost'
- ROUNDCUBE_DBPORT = 5432
- ROUNDCUBE_DBOPTS = ''
- ROUNDCUBE_DBTTY = ''
- ROUNDCUBE_DBUSER = 'postgres'
- ROUNDCUBE_DBPASS = ''
- ROUNDCUBE_DBNAME = 'roundcube'
+ roundcube_dbhost = 'localhost'
+ roundcube_dbport = 5432
+ roundcube_dbopts = ''
+ roundcube_dbtty = ''
+ roundcube_dbuser = 'postgres'
+ roundcube_dbpass = ''
+ roundcube_dbname = 'roundcube'
end
# Load the default config file first, and let the user override it.
require 'default_configuration'
-userconf_path = ENV['HOME'] + '/.mailshears.conf'
+userconf_path = ENV['HOME'] + '/.mailshears.conf.rb'
begin
# Don't crash if it doesn't exist. Maybe he likes the defaults?
require userconf_path
rescue LoadError
end
-Configuration::PLUGINS.each do |plugin_file|
+Configuration::plugins.each do |plugin_file|
require "mailshears/plugins/#{plugin_file}"
end
include Plugin
def initialize
- @domain_root = Configuration::MAIL_ROOT
+ @domain_root = Configuration::mail_root
end
def describe_domain(domain)
include Plugin
def initialize()
- @db_host = Configuration::ROUNDCUBE_DBHOST
- @db_port = Configuration::ROUNDCUBE_DBPORT
- @db_opts = Configuration::ROUNDCUBE_DBOPTS
- @db_tty = Configuration::ROUNDCUBE_DBTTY
- @db_name = Configuration::ROUNDCUBE_DBNAME
- @db_user = Configuration::ROUNDCUBE_DBUSER
- @db_pass = Configuration::ROUNDCUBE_DBPASS
+ @db_host = Configuration::roundcube_dbhost
+ @db_port = Configuration::roundcube_dbport
+ @db_opts = Configuration::roundcube_dbopts
+ @db_tty = Configuration::roundcube_dbtty
+ @db_name = Configuration::roundcube_dbname
+ @db_user = Configuration::roundcube_dbuser
+ @db_pass = Configuration::roundcube_dbpass
end