Sha256: b351ad747dce9badeef07aeee0fbe0e79b49128731da52e400d2e278f70c3a82

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

namespace :postfix do
  def put_sudo(data, to)
    filename = File.basename(to)
    to_directory = File.dirname(to)
    put data, "/tmp/#{filename}"
    run "#{sudo} mv /tmp/#{filename} #{to_directory}"
  end

  def template_sudo(from, to)
    erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
    put_sudo ERB.new(erb).result(binding), to
  end

  desc "Install latest stable release of postfix"
  task :install, roles: :web do
    run "#{sudo} DEBIAN_FRONTEND=noninteractive apt-get -y install postfix"
    run "#{sudo} apt-get install -y dkim-filter"
    run "#{sudo} mkdir -p /etc/postfix/dkim"
    run "#{sudo} dkim-genkey -d #{fqdn} -s mail -r -D /etc/postfix/dkim/"
    run "#{sudo} mv /etc/postfix/dkim/mail.private /etc/postfix/dkim/mail"
    template_sudo "dkim-keys.conf.erb", "/etc/dkim-keys.conf"
    template_sudo "dkim-filter.defaults.erb", "/etc/default/dkim-filter"
    run "#{sudo} chgrp postfix /etc/postfix/dkim/"
    run "#{sudo} chmod 750 /etc/postfix/dkim/"
    template_sudo "main.cf.erb", "/etc/postfix/main.cf"
    template_sudo "dkim-filter.conf.erb", "/etc/dkim-filter.conf"
    restart
  end
  after "deploy:install", "postfix:install"

  %w[start stop restart].each do |command|
    desc "#{command} postfix"
    task command, roles: :web do
      run "#{sudo} service postfix #{command} && #{sudo} service dkim-filter #{command}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
redde-0.1.1 lib/generators/redde/deploy/templates/recipes/postfix.rb
redde-0.1.0 lib/generators/redde/deploy/templates/recipes/postfix.rb
redde-0.0.8 lib/generators/redde/deploy/templates/recipes/postfix.rb
redde-0.0.7 lib/generators/redde/deploy/templates/recipes/postfix.rb
redde-0.0.6 lib/generators/redde/deploy/templates/recipes/postfix.rb
redde-0.0.5 lib/generators/redde/deploy/templates/recipes/postfix.rb
redde-0.0.4 lib/generators/redde/deploy/templates/recipes/postfix.rb
redde-0.0.3 lib/generators/redde/deploy/templates/recipes/postfix.rb