Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ec6bc28241
Fetching contributors…

Cannot retrieve contributors at this time

file 51 lines (41 sloc) 1.069 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
meta :postfix do
  def postfix_conf
    "/etc/postfix/main.cf"
  end

  def restart_postfix
    if postfix_running?
      log_shell "restarting postfix", "/etc/init.d/postfix restart", :sudo => true
    end
  end

  def postfix_running?
    shell? "netstat -an | grep -E '^tcp.*[.:]25 +.*LISTEN'"
  end
end

dep 'postfix.managed'

dep 'running.postfix' do

  requires 'configured.postfix'

  met? {
    postfix_running?.tap {|result|
      log "There is #{result ? 'something' : 'nothing'} listening on port 25."
    }
  }

  meet :on => :linux do
    sudo '/etc/init.d/postfix start'
  end
  meet :on => :osx do
    log_error "launchctl should have already started postfix. Check /var/log/system.log for errors."
  end
end

dep 'configured.postfix' do
  def hostname
    shell('hostname -f').chomp
  end

  requires 'postfix.managed'
  met? {
    Babushka::Renderable.new(postfix_conf).from?(dependency.load_path.parent / "postfix/main.cf.erb")
  }
  meet {
    render_erb 'postfix/main.cf.erb', :to => postfix_conf, :sudo => true
  }

  after { restart_postfix }
end
Something went wrong with that request. Please try again.