Skip to content

Commit

Permalink
Adding a better installation procedure.
Browse files Browse the repository at this point in the history
  • Loading branch information
sts committed May 6, 2012
1 parent d4bebda commit c17eb3c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 61 deletions.
41 changes: 11 additions & 30 deletions README.md
Expand Up @@ -10,44 +10,25 @@ Please note, Smailr is still in development!

## Installation

Install Smailr
Install Packages

# gem install smailr
# aptitude install exim4-daemon-heavy dovecot-imapd dovecot-pop3d

Add a user which will own the mails and is used for the LDA
# aptitude install rubygems libsqlite3-dev

# useradd -r -d /srv/mail vmail
# mkdir /srv/mail/users
# chown -R vmail:vmail /srv/mail
Install Smailr Gem package

Install Exim and Dovecot
# gem install smailr

# aptitude install exim-daemon-heavy dovecot-imapd dovecot-pop3d
Generate the Smailr configuration in /etc/smailr.yml

Install the example Exim and Dovecot configration files on your mailserver.
# smailr setup

please review the configuration file, then run 'setup' again:

# smailr setup
*****************************************************************
All needed configuration files are in ./smailr-etc for review.

Please install exim4, dovecot and then run the commands below, or
adjust the file locations according to your environment.

Also make sure to configure a location for the SQLite database
file in samilr.yml.

Then run 'smailr migrate' to initialize the database.
*****************************************************************

cp smailr-etc/smailr.yml /etc/smailr.yml
cp smailr-etc/dovecot.conf /etc/dovecot/
cp smailr-etc/dovecot-sql.conf /etc/dovecot/
cp smailr-etc/exim4/

# invoke-rc.d exim4 restart
# invoke-rc.d dovecot restart

Run the setup command to initialize the smailr database run:

To initialize the database run all migrations

# smailr migrate

Expand Down
64 changes: 33 additions & 31 deletions lib/smailr.rb
Expand Up @@ -6,7 +6,7 @@
require 'fileutils'

module Smailr
VERSION = '0.5.0'
VERSION = '0.5.1'

autoload :Model, 'smailr/model'
autoload :Domain, 'smailr/domain'
Expand Down Expand Up @@ -39,38 +39,40 @@ def self.db_connect
def self.setup
prefix = self.contrib_directory

FileUtils.mkdir_p "smailr-etc/exim4"
FileUtils.mkdir_p "smailr-etc/dovecot"

FileUtils.cp File.expand_path("../README.md", prefix), "smailr-etc/"
FileUtils.cp File.expand_path("../smailr.yml", prefix), "smailr-etc/"
FileUtils.cp File.expand_path("exim4.conf", prefix), "smailr-etc/exim4"
FileUtils.cp File.expand_path("dovecot.conf", prefix), "smailr-etc/dovecot"
FileUtils.cp File.expand_path("dovecot-sql.conf", prefix),"smailr-etc/dovecot"
if not File.exists?("/etc/smailr.yml")
if not File.writable?("/etc")
say_error "Cannot copy configuration to /etc/smailr.yml - permission denied."
exit 1
end
FileUtils.cp File.expand_path("../smailr.yml", prefix), "/etc/smailr.yml"
say "Configuration installed in /etc/smailr.yml. Please revise, then run 'smailr setup' again."
else
# Only install configuration if needed
if config["exim_path"]
if File.writable?(config["exim_path"])
FileUtils.cp File.expand_path("/exim4.conf", prefix), config["exim_path"]
else
say_error "Cannot copy Exim configuration to #{config["exim_path"]} - permission denied or path doesn't exist."
exit 1
end
end

say "*****************************************************************"
say "All needed configuration files are in ./smailr-etc for review."
say "\n"
say "Please install exim4, dovecot and then run the commands below, or"
say "adjust the file locations according to your environment."
say "\n"
say "Also make sure to configure a location for the SQLite database"
say "file in smailr.yml."
say "\n"
say "Then run 'smailr migrate' to initialize the database."
say "*****************************************************************"
say "\n"
say "cp smailr-etc/smailr.yml /etc/smailr.yml"
say "cp smailr-etc/dovecot.conf /etc/dovecot/"
say "cp smailr-etc/dovecot-sql.conf /etc/dovecot/"
say "cp smailr-etc/exim4/"
if config["dovecot_path"]
if File.writable?(config["dovecot_path"])
FileUtils.cp File.expand_path("/dovecot.conf", prefix), config["dovecot_path"]
FileUtils.cp File.expand_path("/dovecot-sql.conf", prefix), config["dovecot_path"]
else
say_error "Cannot copy Dovecot configuration to #{config["dovecot_path"]} - permission denied or path doesn't exist."
exit 1
end
end

# Future version could maybe launch puppet here?
#
#instalpp = File.expand_path('/install.pp', self.contrib_directory)
#if agree("Shall we launch puppet with the manifest from #{installpp}? (yes/no) ")
# exec "puppet apply #{installpp}"
#end
if config["mail_spool_path"]
exec "useradd -r -d #{config["mail_spool_path"]} vmail"
FileUtils.mkdir_p "#{config["mail_spool_path"]}/users"
FileUtils.chown "vmail", "vmail", config["mail_spool_path"]
end
end
end
end

Expand Down
4 changes: 4 additions & 0 deletions smailr.yml
@@ -1,4 +1,8 @@
---
exim_path: /etc/exim4
dovecot_path: /etc/dovecot
mail_spool_path: /srv/mail

database:
adapter: sqlite
database: /etc/exim4/smailr.sqlite
Expand Down

0 comments on commit c17eb3c

Please sign in to comment.