This repository was archived by the owner on Jul 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpostfix.rb
More file actions
67 lines (53 loc) · 1.43 KB
/
postfix.rb
File metadata and controls
67 lines (53 loc) · 1.43 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
meta :postfix do
def postfix_conf
"/etc/postfix/main.cf"
end
def sasl_passwd
"/etc/postfix/sasl_passwd"
end
def start_postfix
log_shell "Starting postfix...", "systemctl start postfix"
end
def restart_postfix
if postfix_running?
log_shell "Restarting postfix...", "systemctl restart postfix"
end
end
def postfix_running?
shell? "systemctl is-active postfix"
end
end
dep "postfix.bin"
dep "mailutils.bin"
dep "running.postfix" do
requires "configured.postfix"
met? do
postfix_running?.tap do |result|
log "There is #{result ? 'something' : 'nothing'} listening on port 25."
end
end
meet on: :linux do
start_postfix
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", :mailgun_password do
def hostname
shell("hostname -f").chomp
end
requires "postfix.bin"
requires "mailutils.bin"
met? do
Babushka::Renderable.new(postfix_conf).from?(dependency.load_path.parent / "postfix/main.cf.erb")
Babushka::Renderable.new(sasl_passwd).from?(dependency.load_path.parent / "postfix/sasl_passwd.erb")
end
meet do
render_erb "postfix/main.cf.erb", to: postfix_conf
render_erb "postfix/sasl_passwd.erb", to: sasl_passwd
shell "chmod 600 /etc/postfix/sasl_passwd"
shell "postmap /etc/postfix/sasl_passwd"
end
after { restart_postfix }
end