blob: 77ce8916e56ab067e660f7bdd4319f40f32097d3 (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
web_server "monchichi" do
one "something"
two "something else"
end
runit_service "bobo" do
directory "monkey"
downif "/bin/false is true"
templatedir "something"
end
define :runit_service, :directory => "/etc/sv", :downif => "/bin/false", :templatedir => nil do
require_recipe "runit"
validate(
params,
{
:directory => { :required => true },
:downif => { :required => true },
:templatedir => { :required => false },
}
)
file "#{param[:directory]}-#{param[:name]}" do
path "#{param[:directory]}/#{param[:name]}"
insure "directory"
owner "root"
group "root"
mode 0755
end
file "#{param[:directory]}/#{param[:name]}/log" do
insure "directory"
owner "root"
group "root"
mode 0755
end
file "#{param[:directory]}/#{param[:name]}/log/main" do
insure "directory"
owner "root"
group "root"
mode 0755
end
symlink "/etc/init.d/#{param[:name]}" do
sv_dir = case node[:lsbdistid]
when 'CentOS': "/usr/local/bin/sv"
else: "/usr/bin/sv"
end
source_file = sv_dir
end
symlink "/var/service/#{param[:name]}" do
source_file "#{param[:directory]}/#{param[:name]}"
end
service "#{param[:name]}" do
has_restart true
has_status true
end
template_file "#{param[:directory]}/#{param[:name]}/log/run" do
content "#{param[:templatedir]}/log-run.erb"
owner "root"
group "root"
mode 755
notifies resource("service[#{param[:name]}]")
end
template_file "#{param[:directory]}/#{param[:name]}/run" do
content "#{param[:templatedir]}/run.erb"
owner root
group root
mode 755
notifies resource("service[#{param[:name]}]")
end
exec "#{param[:name]}-down" do
command "/etc/init.d/#{param[:name]} down"
only_if "#{downif}"
end
end
|