from-scratch 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Berksfile +2 -1
- data/Berksfile.lock +20 -1
- data/cookbooks/bluepill/CHANGELOG.md +93 -0
- data/cookbooks/bluepill/README.md +91 -0
- data/cookbooks/bluepill/attributes/default.rb +44 -0
- data/cookbooks/bluepill/metadata.json +1 -0
- data/cookbooks/bluepill/providers/service.rb +172 -0
- data/cookbooks/bluepill/recipes/default.rb +48 -0
- data/cookbooks/bluepill/recipes/rsyslog.rb +28 -0
- data/cookbooks/bluepill/resources/service.rb +27 -0
- data/cookbooks/bluepill/templates/default/bluepill_init.fedora.erb +34 -0
- data/cookbooks/bluepill/templates/default/bluepill_init.freebsd.erb +32 -0
- data/cookbooks/bluepill/templates/default/bluepill_init.lsb.erb +37 -0
- data/cookbooks/bluepill/templates/default/bluepill_init.rhel.erb +34 -0
- data/cookbooks/bluepill/templates/default/bluepill_rsyslog.conf.erb +1 -0
- data/cookbooks/nginx/CHANGELOG.md +435 -0
- data/cookbooks/nginx/README.md +521 -0
- data/cookbooks/nginx/attributes/auth_request.rb +23 -0
- data/cookbooks/nginx/attributes/default.rb +131 -0
- data/cookbooks/nginx/attributes/devel.rb +24 -0
- data/cookbooks/nginx/attributes/echo.rb +24 -0
- data/cookbooks/nginx/attributes/geoip.rb +31 -0
- data/cookbooks/nginx/attributes/headers_more.rb +24 -0
- data/cookbooks/nginx/attributes/lua.rb +28 -0
- data/cookbooks/nginx/attributes/naxsi.rb +24 -0
- data/cookbooks/nginx/attributes/openssl_source.rb +23 -0
- data/cookbooks/nginx/attributes/pagespeed.rb +9 -0
- data/cookbooks/nginx/attributes/passenger.rb +58 -0
- data/cookbooks/nginx/attributes/rate_limiting.rb +23 -0
- data/cookbooks/nginx/attributes/repo.rb +35 -0
- data/cookbooks/nginx/attributes/set_misc.rb +8 -0
- data/cookbooks/nginx/attributes/socketproxy.rb +13 -0
- data/cookbooks/nginx/attributes/source.rb +42 -0
- data/cookbooks/nginx/attributes/status.rb +22 -0
- data/cookbooks/nginx/attributes/syslog.rb +24 -0
- data/cookbooks/nginx/attributes/upload_progress.rb +26 -0
- data/cookbooks/nginx/definitions/nginx_site.rb +50 -0
- data/cookbooks/nginx/files/default/mime.types +78 -0
- data/cookbooks/nginx/files/default/naxsi_core.rules +82 -0
- data/cookbooks/nginx/libraries/matchers.rb +20 -0
- data/cookbooks/nginx/metadata.json +351 -0
- data/cookbooks/nginx/recipes/authorized_ips.rb +32 -0
- data/cookbooks/nginx/recipes/commons.rb +24 -0
- data/cookbooks/nginx/recipes/commons_conf.rb +42 -0
- data/cookbooks/nginx/recipes/commons_dir.rb +57 -0
- data/cookbooks/nginx/recipes/commons_script.rb +29 -0
- data/cookbooks/nginx/recipes/default.rb +31 -0
- data/cookbooks/nginx/recipes/headers_more_module.rb +50 -0
- data/cookbooks/nginx/recipes/http_auth_request_module.rb +52 -0
- data/cookbooks/nginx/recipes/http_echo_module.rb +46 -0
- data/cookbooks/nginx/recipes/http_geoip_module.rb +113 -0
- data/cookbooks/nginx/recipes/http_gzip_static_module.rb +30 -0
- data/cookbooks/nginx/recipes/http_mp4_module.rb +2 -0
- data/cookbooks/nginx/recipes/http_perl_module.rb +23 -0
- data/cookbooks/nginx/recipes/http_realip_module.rb +38 -0
- data/cookbooks/nginx/recipes/http_spdy_module.rb +23 -0
- data/cookbooks/nginx/recipes/http_ssl_module.rb +23 -0
- data/cookbooks/nginx/recipes/http_stub_status_module.rb +36 -0
- data/cookbooks/nginx/recipes/ipv6.rb +23 -0
- data/cookbooks/nginx/recipes/lua.rb +47 -0
- data/cookbooks/nginx/recipes/naxsi_module.rb +52 -0
- data/cookbooks/nginx/recipes/ngx_devel_module.rb +44 -0
- data/cookbooks/nginx/recipes/ngx_lua_module.rb +47 -0
- data/cookbooks/nginx/recipes/ohai_plugin.rb +35 -0
- data/cookbooks/nginx/recipes/openssl_source.rb +45 -0
- data/cookbooks/nginx/recipes/package.rb +52 -0
- data/cookbooks/nginx/recipes/pagespeed_module.rb +62 -0
- data/cookbooks/nginx/recipes/passenger.rb +56 -0
- data/cookbooks/nginx/recipes/repo.rb +41 -0
- data/cookbooks/nginx/recipes/repo_passenger.rb +39 -0
- data/cookbooks/nginx/recipes/set_misc.rb +30 -0
- data/cookbooks/nginx/recipes/socketproxy.rb +26 -0
- data/cookbooks/nginx/recipes/source.rb +205 -0
- data/cookbooks/nginx/recipes/syslog_module.rb +69 -0
- data/cookbooks/nginx/recipes/upload_progress_module.rb +53 -0
- data/cookbooks/nginx/templates/debian/nginx.init.erb +97 -0
- data/cookbooks/nginx/templates/default/default-site.erb +11 -0
- data/cookbooks/nginx/templates/default/modules/authorized_ip.erb +6 -0
- data/cookbooks/nginx/templates/default/modules/http_geoip.conf.erb +4 -0
- data/cookbooks/nginx/templates/default/modules/http_gzip_static.conf.erb +1 -0
- data/cookbooks/nginx/templates/default/modules/http_realip.conf.erb +7 -0
- data/cookbooks/nginx/templates/default/modules/nginx_status.erb +14 -0
- data/cookbooks/nginx/templates/default/modules/passenger.conf.erb +13 -0
- data/cookbooks/nginx/templates/default/modules/socketproxy.conf.erb +89 -0
- data/cookbooks/nginx/templates/default/modules/upload_progress.erb +4 -0
- data/cookbooks/nginx/templates/default/nginx-upstart.conf.erb +39 -0
- data/cookbooks/nginx/templates/default/nginx.conf.erb +103 -0
- data/cookbooks/nginx/templates/default/nginx.init.erb +111 -0
- data/cookbooks/nginx/templates/default/nginx.pill.erb +15 -0
- data/cookbooks/nginx/templates/default/nginx.sysconfig.erb +1 -0
- data/cookbooks/nginx/templates/default/nxdissite.erb +29 -0
- data/cookbooks/nginx/templates/default/nxensite.erb +38 -0
- data/cookbooks/nginx/templates/default/plugins/nginx.rb.erb +66 -0
- data/cookbooks/nginx/templates/default/sv-nginx-log-run.erb +2 -0
- data/cookbooks/nginx/templates/default/sv-nginx-run.erb +4 -0
- data/cookbooks/nginx/templates/gentoo/nginx.init.erb +87 -0
- data/cookbooks/nginx/templates/suse/nginx.init.erb +115 -0
- data/cookbooks/nginx/templates/ubuntu/nginx.init.erb +97 -0
- data/cookbooks/ohai/CHANGELOG.md +69 -0
- data/cookbooks/ohai/README.md +89 -0
- data/cookbooks/ohai/attributes/default.rb +31 -0
- data/cookbooks/ohai/files/default/plugins/README +1 -0
- data/cookbooks/ohai/libraries/matchers.rb +14 -0
- data/cookbooks/ohai/metadata.json +1 -0
- data/cookbooks/ohai/providers/hint.rb +38 -0
- data/cookbooks/ohai/recipes/default.rb +52 -0
- data/cookbooks/ohai/resources/hint.rb +5 -0
- data/cookbooks/packagecloud/CHANGELOG.md +12 -0
- data/cookbooks/packagecloud/README.md +80 -0
- data/cookbooks/packagecloud/attributes/default.rb +8 -0
- data/cookbooks/packagecloud/libraries/helper.rb +43 -0
- data/cookbooks/packagecloud/libraries/matcher.rb +7 -0
- data/cookbooks/packagecloud/metadata.json +1 -0
- data/cookbooks/packagecloud/providers/repo.rb +212 -0
- data/cookbooks/packagecloud/resources/repo.rb +10 -0
- data/cookbooks/packagecloud/templates/.kitchen/logs/kitchen.log +29 -0
- data/cookbooks/packagecloud/templates/default/apt.erb +2 -0
- data/cookbooks/packagecloud/templates/default/yum.erb +15 -0
- data/cookbooks/rsyslog/CHANGELOG.md +193 -0
- data/cookbooks/rsyslog/README.md +276 -0
- data/cookbooks/rsyslog/attributes/default.rb +131 -0
- data/cookbooks/rsyslog/libraries/helpers.rb +25 -0
- data/cookbooks/rsyslog/metadata.json +1 -0
- data/cookbooks/rsyslog/providers/file_input.rb +44 -0
- data/cookbooks/rsyslog/recipes/client.rb +87 -0
- data/cookbooks/rsyslog/recipes/default.rb +89 -0
- data/cookbooks/rsyslog/recipes/server.rb +44 -0
- data/cookbooks/rsyslog/resources/file_input.rb +28 -0
- data/cookbooks/rsyslog/templates/default/35-server-per-host.conf.erb +62 -0
- data/cookbooks/rsyslog/templates/default/49-relp.conf.erb +10 -0
- data/cookbooks/rsyslog/templates/default/49-remote.conf.erb +30 -0
- data/cookbooks/rsyslog/templates/default/50-default.conf.erb +6 -0
- data/cookbooks/rsyslog/templates/default/file-input.conf.erb +15 -0
- data/cookbooks/rsyslog/templates/default/omnios-manifest.xml.erb +30 -0
- data/cookbooks/rsyslog/templates/default/rsyslog.conf.erb +117 -0
- data/cookbooks/rsyslog/templates/smartos/50-default.conf.erb +18 -0
- data/cookbooks/runit/.kitchen.cloud.yml +103 -0
- data/cookbooks/runit/.kitchen.yml +38 -0
- data/cookbooks/runit/.rspec +3 -0
- data/cookbooks/runit/.rubocop.yml +45 -0
- data/cookbooks/runit/Berksfile.disabled +11 -0
- data/cookbooks/runit/CHANGELOG.md +226 -0
- data/cookbooks/runit/CONTRIBUTING.md +266 -0
- data/cookbooks/runit/Cheffile +11 -0
- data/cookbooks/runit/Gemfile +17 -0
- data/cookbooks/runit/LICENSE +201 -0
- data/cookbooks/runit/README.md +435 -0
- data/cookbooks/runit/Rakefile +23 -0
- data/cookbooks/runit/TESTING.md +26 -0
- data/cookbooks/runit/attributes/default.rb +62 -0
- data/cookbooks/runit/files/default/runit.seed +1 -0
- data/cookbooks/runit/files/default/runsvdir +0 -0
- data/cookbooks/runit/files/ubuntu-6.10/runsvdir +6 -0
- data/cookbooks/runit/files/ubuntu-7.04/runsvdir +7 -0
- data/cookbooks/runit/files/ubuntu-7.10/runsvdir +7 -0
- data/cookbooks/runit/files/ubuntu-8.04/runsvdir +7 -0
- data/cookbooks/runit/libraries/default.rb +0 -0
- data/cookbooks/runit/libraries/helpers.rb +190 -0
- data/cookbooks/runit/libraries/matchers.rb +69 -0
- data/cookbooks/runit/libraries/provider_runit_service.rb +326 -0
- data/cookbooks/runit/libraries/resource_runit_service.rb +267 -0
- data/cookbooks/runit/metadata.json +50 -0
- data/cookbooks/runit/recipes/default.rb +91 -0
- data/cookbooks/runit/templates/debian/init.d.erb +66 -0
- data/cookbooks/runit/templates/default/log-config.erb +24 -0
- data/cookbooks/runit/templates/gentoo/runit-start.sh.erb +32 -0
- data/cookbooks/scratchify/Berksfile +2 -1
- data/cookbooks/scratchify/Berksfile.lock +20 -1
- data/cookbooks/scratchify/lib/from-scratch.rb +1 -4
- data/cookbooks/scratchify/lib/from-scratch/version.rb +1 -1
- data/cookbooks/scratchify/metadata.json +5 -2
- data/cookbooks/scratchify/recipes/default.rb +15 -1
- data/cookbooks/scratchify/recipes/nginx_site.rb +4 -0
- data/cookbooks/scratchify/recipes/pre_rvm.rb +5 -0
- data/cookbooks/scratchify/templates/nginx.erb +31 -0
- data/cookbooks/scratchify/templates/node.json.erb +21 -6
- data/cookbooks/yum-epel/CHANGELOG.md +84 -0
- data/cookbooks/yum-epel/README.md +172 -0
- data/cookbooks/yum-epel/attributes/default.rb +1 -0
- data/cookbooks/yum-epel/attributes/epel-debuginfo.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel-source.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel-testing-debuginfo.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel-testing-source.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel-testing.rb +28 -0
- data/cookbooks/yum-epel/attributes/epel.rb +28 -0
- data/cookbooks/yum-epel/metadata.json +1 -0
- data/cookbooks/yum-epel/recipes/default.rb +61 -0
- data/cookbooks/yum/CHANGELOG.md +294 -0
- data/cookbooks/yum/README.md +285 -0
- data/cookbooks/yum/attributes/main.rb +100 -0
- data/cookbooks/yum/libraries/matchers.rb +27 -0
- data/cookbooks/yum/metadata.json +1 -0
- data/cookbooks/yum/providers/globalconfig.rb +41 -0
- data/cookbooks/yum/providers/repository.rb +106 -0
- data/cookbooks/yum/recipes/default.rb +26 -0
- data/cookbooks/yum/resources/globalconfig.rb +109 -0
- data/cookbooks/yum/resources/repository.rb +69 -0
- data/cookbooks/yum/templates/default/main.erb +276 -0
- data/cookbooks/yum/templates/default/repo.erb +125 -0
- data/lib/from-scratch.rb +1 -0
- data/lib/from-scratch/version.rb +1 -1
- data/metadata.rb +5 -1
- data/recipes/default.rb +15 -1
- data/recipes/nginx_site.rb +4 -0
- data/recipes/pre_rvm.rb +5 -0
- data/templates/nginx.erb +31 -0
- data/templates/node.json.erb +21 -6
- metadata +194 -1
@@ -0,0 +1,267 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: runit
|
3
|
+
# Provider:: service
|
4
|
+
#
|
5
|
+
# Copyright 2011, Joshua Timberman
|
6
|
+
# Copyright 2011, Chef Software, Inc.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'chef/resource'
|
22
|
+
require 'chef/resource/service'
|
23
|
+
|
24
|
+
class Chef
|
25
|
+
class Resource
|
26
|
+
# Missing top-level class documentation comment
|
27
|
+
class RunitService < Chef::Resource::Service
|
28
|
+
def initialize(name, run_context = nil)
|
29
|
+
super
|
30
|
+
runit_node = runit_attributes_from_node(run_context)
|
31
|
+
@resource_name = :runit_service
|
32
|
+
@provider = Chef::Provider::RunitService
|
33
|
+
@supports = { restart: true, reload: true, status: true }
|
34
|
+
@action = :enable
|
35
|
+
@allowed_actions = [:nothing, :start, :stop, :enable, :disable, :restart, :reload, :status, :once, :hup, :cont, :term, :kill, :up, :down, :usr1, :usr2, :create]
|
36
|
+
|
37
|
+
# sv_bin, sv_dir, service_dir and lsb_init_dir may have been set in the
|
38
|
+
# node attributes
|
39
|
+
@sv_bin = runit_node[:sv_bin] || '/usr/bin/sv'
|
40
|
+
@sv_dir = runit_node[:sv_dir] || '/etc/sv'
|
41
|
+
@service_dir = runit_node[:service_dir] || '/etc/service'
|
42
|
+
@lsb_init_dir = runit_node[:lsb_init_dir] || '/etc/init.d'
|
43
|
+
|
44
|
+
@control = []
|
45
|
+
@options = {}
|
46
|
+
@env = {}
|
47
|
+
@log = true
|
48
|
+
@cookbook = nil
|
49
|
+
@check = false
|
50
|
+
@start_down = false
|
51
|
+
@delete_downfile = false
|
52
|
+
@finish = false
|
53
|
+
@owner = nil
|
54
|
+
@group = nil
|
55
|
+
@enabled = false
|
56
|
+
@running = false
|
57
|
+
@default_logger = false
|
58
|
+
@restart_on_update = true
|
59
|
+
@run_template_name = @service_name
|
60
|
+
@log_template_name = @service_name
|
61
|
+
@check_script_template_name = @service_name
|
62
|
+
@finish_script_template_name = @service_name
|
63
|
+
@control_template_names = {}
|
64
|
+
@status_command = "#{@sv_bin} status #{@service_dir}"
|
65
|
+
@sv_templates = true
|
66
|
+
@sv_timeout = nil
|
67
|
+
@sv_verbose = false
|
68
|
+
@log_dir = ::File.join('/var/log/', @service_name)
|
69
|
+
@log_size = nil
|
70
|
+
@log_num = nil
|
71
|
+
@log_min = nil
|
72
|
+
@log_timeout = nil
|
73
|
+
@log_processor = nil
|
74
|
+
@log_socket = nil
|
75
|
+
@log_prefix = nil
|
76
|
+
@log_config_append = nil
|
77
|
+
|
78
|
+
#
|
79
|
+
# Backward Compat Hack
|
80
|
+
#
|
81
|
+
# This ensures a 'service' resource exists for all 'runit_service' resources.
|
82
|
+
# This should allow all recipes using the previous 'runit_service' definition to
|
83
|
+
# continue operating.
|
84
|
+
#
|
85
|
+
unless run_context.nil?
|
86
|
+
service_dir_name = ::File.join(@service_dir, @name)
|
87
|
+
@service_mirror = Chef::Resource::Service.new(name, run_context)
|
88
|
+
@service_mirror.provider(Chef::Provider::Service::Simple)
|
89
|
+
@service_mirror.supports(@supports)
|
90
|
+
@service_mirror.start_command("#{@sv_bin} start #{service_dir_name}")
|
91
|
+
@service_mirror.stop_command("#{@sv_bin} stop #{service_dir_name}")
|
92
|
+
@service_mirror.restart_command("#{@sv_bin} restart #{service_dir_name}")
|
93
|
+
@service_mirror.status_command("#{@sv_bin} status #{service_dir_name}")
|
94
|
+
@service_mirror.action(:nothing)
|
95
|
+
run_context.resource_collection.insert(@service_mirror)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def sv_bin(arg = nil)
|
100
|
+
set_or_return(:sv_bin, arg, kind_of: [String])
|
101
|
+
end
|
102
|
+
|
103
|
+
def sv_dir(arg = nil)
|
104
|
+
set_or_return(:sv_dir, arg, kind_of: [String, FalseClass])
|
105
|
+
end
|
106
|
+
|
107
|
+
def sv_timeout(arg = nil)
|
108
|
+
set_or_return(:sv_timeout, arg, kind_of: [Fixnum])
|
109
|
+
end
|
110
|
+
|
111
|
+
def sv_verbose(arg = nil)
|
112
|
+
set_or_return(:sv_verbose, arg, kind_of: [TrueClass, FalseClass])
|
113
|
+
end
|
114
|
+
|
115
|
+
def service_dir(arg = nil)
|
116
|
+
set_or_return(:service_dir, arg, kind_of: [String])
|
117
|
+
end
|
118
|
+
|
119
|
+
def lsb_init_dir(arg = nil)
|
120
|
+
set_or_return(:lsb_init_dir, arg, kind_of: [String])
|
121
|
+
end
|
122
|
+
|
123
|
+
def control(arg = nil)
|
124
|
+
set_or_return(:control, arg, kind_of: [Array])
|
125
|
+
end
|
126
|
+
|
127
|
+
def options(arg = nil)
|
128
|
+
default_opts = @env.empty? ? @options : @options.merge(env_dir: ::File.join(@sv_dir, @service_name, 'env'))
|
129
|
+
|
130
|
+
merged_opts = arg.respond_to?(:merge) ? default_opts.merge(arg) : default_opts
|
131
|
+
|
132
|
+
set_or_return(
|
133
|
+
:options,
|
134
|
+
merged_opts,
|
135
|
+
kind_of: [Hash],
|
136
|
+
default: default_opts
|
137
|
+
)
|
138
|
+
end
|
139
|
+
|
140
|
+
def env(arg = nil)
|
141
|
+
set_or_return(:env, arg, kind_of: [Hash])
|
142
|
+
end
|
143
|
+
|
144
|
+
## set log to current instance value if nothing is passed.
|
145
|
+
def log(arg = @log)
|
146
|
+
set_or_return(:log, arg, kind_of: [TrueClass, FalseClass])
|
147
|
+
end
|
148
|
+
|
149
|
+
def cookbook(arg = nil)
|
150
|
+
set_or_return(:cookbook, arg, kind_of: [String])
|
151
|
+
end
|
152
|
+
|
153
|
+
def finish(arg = nil)
|
154
|
+
set_or_return(:finish, arg, kind_of: [TrueClass, FalseClass])
|
155
|
+
end
|
156
|
+
|
157
|
+
def check(arg = nil)
|
158
|
+
set_or_return(:check, arg, kind_of: [TrueClass, FalseClass])
|
159
|
+
end
|
160
|
+
|
161
|
+
def start_down(arg = nil)
|
162
|
+
set_or_return(:start_down, arg, kind_of: [TrueClass, FalseClass])
|
163
|
+
end
|
164
|
+
|
165
|
+
def delete_downfile(arg = nil)
|
166
|
+
set_or_return(:delete_downfile, arg, kind_of: [TrueClass, FalseClass])
|
167
|
+
end
|
168
|
+
|
169
|
+
def owner(arg = nil)
|
170
|
+
set_or_return(:owner, arg, regex: [Chef::Config[:user_valid_regex]])
|
171
|
+
end
|
172
|
+
|
173
|
+
def group(arg = nil)
|
174
|
+
set_or_return(:group, arg, regex: [Chef::Config[:group_valid_regex]])
|
175
|
+
end
|
176
|
+
|
177
|
+
def default_logger(arg = nil)
|
178
|
+
set_or_return(:default_logger, arg, kind_of: [TrueClass, FalseClass])
|
179
|
+
end
|
180
|
+
|
181
|
+
def restart_on_update(arg = nil)
|
182
|
+
set_or_return(:restart_on_update, arg, kind_of: [TrueClass, FalseClass])
|
183
|
+
end
|
184
|
+
|
185
|
+
def run_template_name(arg = nil)
|
186
|
+
set_or_return(:run_template_name, arg, kind_of: [String])
|
187
|
+
end
|
188
|
+
alias_method :template_name, :run_template_name
|
189
|
+
|
190
|
+
def log_template_name(arg = nil)
|
191
|
+
set_or_return(:log_template_name, arg, kind_of: [String])
|
192
|
+
end
|
193
|
+
|
194
|
+
def check_script_template_name(arg = nil)
|
195
|
+
set_or_return(:check_script_template_name, arg, kind_of: [String])
|
196
|
+
end
|
197
|
+
|
198
|
+
def finish_script_template_name(arg = nil)
|
199
|
+
set_or_return(:finish_script_template_name, arg, kind_of: [String])
|
200
|
+
end
|
201
|
+
|
202
|
+
def control_template_names(arg = nil)
|
203
|
+
set_or_return(
|
204
|
+
:control_template_names,
|
205
|
+
arg,
|
206
|
+
kind_of: [Hash],
|
207
|
+
default: set_control_template_names
|
208
|
+
)
|
209
|
+
end
|
210
|
+
|
211
|
+
def set_control_template_names
|
212
|
+
@control.each do |signal|
|
213
|
+
@control_template_names[signal] ||= @service_name
|
214
|
+
end
|
215
|
+
@control_template_names
|
216
|
+
end
|
217
|
+
|
218
|
+
def sv_templates(arg = nil)
|
219
|
+
set_or_return(:sv_templates, arg, kind_of: [TrueClass, FalseClass])
|
220
|
+
end
|
221
|
+
|
222
|
+
def log_dir(arg = nil)
|
223
|
+
set_or_return(:log_dir, arg, kind_of: [String])
|
224
|
+
end
|
225
|
+
|
226
|
+
def log_size(arg = nil)
|
227
|
+
set_or_return(:log_size, arg, kind_of: [Integer])
|
228
|
+
end
|
229
|
+
|
230
|
+
def log_num(arg = nil)
|
231
|
+
set_or_return(:log_num, arg, kind_of: [Integer])
|
232
|
+
end
|
233
|
+
|
234
|
+
def log_min(arg = nil)
|
235
|
+
set_or_return(:log_min, arg, kind_of: [Integer])
|
236
|
+
end
|
237
|
+
|
238
|
+
def log_timeout(arg = nil)
|
239
|
+
set_or_return(:log_timeout, arg, kind_of: [Integer])
|
240
|
+
end
|
241
|
+
|
242
|
+
def log_processor(arg = nil)
|
243
|
+
set_or_return(:log_processor, arg, kind_of: [String])
|
244
|
+
end
|
245
|
+
|
246
|
+
def log_socket(arg = nil)
|
247
|
+
set_or_return(:log_socket, arg, kind_of: [String, Hash])
|
248
|
+
end
|
249
|
+
|
250
|
+
def log_prefix(arg = nil)
|
251
|
+
set_or_return(:log_prefix, arg, kind_of: [String])
|
252
|
+
end
|
253
|
+
|
254
|
+
def log_config_append(arg = nil)
|
255
|
+
set_or_return(:log_config_append, arg, kind_of: [String])
|
256
|
+
end
|
257
|
+
|
258
|
+
def runit_attributes_from_node(run_context)
|
259
|
+
if run_context && run_context.node && run_context.node[:runit]
|
260
|
+
run_context.node[:runit]
|
261
|
+
else
|
262
|
+
{}
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{
|
2
|
+
"name": "runit",
|
3
|
+
"description": "Installs runit and provides runit_service definition",
|
4
|
+
"long_description": "runit Cookbook\n==============\nInstalls runit and provides the `runit_service` service resource for managing processes (services) under runit.\n\nThis cookbook does not use runit to replace system init, nor are ther plans to do so.\n\nFor more information about runit:\n\n- http://smarden.org/runit/\n\n#### A note regarding versions 1.7.0 and 1.7.2\n\nWith the benefit of hindsight we can say that the changes contained version 1.7.0 merited a major version number change, and that version 1.7.2 contains some still unresolved regressions compared to 1.6.0. Please be sure to test this new version for compatibility with your systems before upgrading to version 1.7.\n\nSee [issue #144](https://github.com/hw-cookbooks/runit/issues/144) for some notes on how these versions behaved unexpectedly in one user's environment.\n\nRequirements\n------------\n### Platforms\n- Debian/Ubuntu\n- Gentoo\n- RHEL\n\n### Cookbooks\n- packagecloud (for RHEL)\n\nAttributes\n----------\nSee `attributes/default.rb` for defaults generated per platform.\n\n- `node['runit']['sv_bin']` - Full path to the `sv` binary.\n- `node['runit']['chpst_bin']` - Full path to the `chpst` binary.\n- `node['runit']['service_dir']` - Full path to the default \"services\" directory where enabled services are linked.\n- `node['runit']['sv_dir']` - Full path to the directory where service lives, which gets linked to `service_dir`.\n- `node['runit']['lsb_init_dir']` - Full path to the directory where the LSB-compliant init script interface will be created.\n- `node['runit']['start']` - Command to start the runsvdir service\n- `node['runit']['stop]` - Command to stop the runsvdir service\n- `node['runit']['reload']` - Command to reload the runsvdir service\n\n### Optional Attributes for RHEL systems\n\n- `node['runit']['prefer_local_yum']` - If `true`, assumes that a `runit` package is available on an already configured local yum repository. By default, the recipe installs the `runit` package from a Package Cloud repository (see below). This is set to the value of `node['runit']['use_package_from_yum']` for backwards compatibility, but otherwise defaults to `false`.\n\nRecipes\n-------\n### default\nThe default recipe installs runit and starts `runsvdir` to supervise the services in runit's service directory (e.g., `/etc/service`).\n\nOn RHEL-family systems, it will install the runit RPM using [Ian Meyer's Package Cloud repository](https://packagecloud.io/imeyer/runit) for runit. This replaces the previous functionality where the RPM was build using his [runit RPM SPEC](https://github.com/imeyer/runit-rpm). However, if the attribute `node['runit']['prefer_local_yum']` is set to `true`, the packagecloud repository creation will be skipped and it is assumed that a `runit` package is available on an otherwise configured (outside this cookbook) local repository.\n\nOn Debian family systems, the runit packages are maintained by the runit author, Gerrit Pape, and the recipe will use that for installation.\n\nOn Gentoo, the runit ebuild package is installed.\n\nResource/Provider\n-----------------\nThis cookbook has a resource, `runit_service`, for managing services under runit. This service subclasses the Chef `service` resource.\n\n**This resource replaces the runit_service definition. See the CHANGELOG.md file in this cookbook for breaking change information and any actions you may need to take to update cookbooks using runit_service.**\n\n### Actions\n- **enable** - enables the service, creating the required run scripts and symlinks. This is the default action.\n- **start** - starts the service with `sv start`\n- **stop** - stops the service with `sv stop`\n- **disable** - stops the service with `sv down` and removes the service symlink\n- **create** - create the service directory, but don't enable the service with symlink\n- **restart** - restarts the service with `sv restart`\n- **reload** - reloads the service with `sv force-reload`\n- **once** - starts the service with `sv once`.\n- **hup** - sends the `HUP` signal to the service with `sv hup`\n- **cont** - sends the `CONT` signal to the service\n- **term** - sends the `TERM` signal to the service\n- **kill** - sends the `KILL` signal to the service\n- **up** - starts the service with `sv up`\n- **down** - downs the service with `sv down`\n- **usr1** - sends the `USR1` signal to the service with `sv 1`\n- **usr2** - sends the `USR2` signal to the service with `sv 2`\n\nService management actions are taken with runit's \"`sv`\" program.\n\nRead the `sv(8)` [man page](http://smarden.org/runit/sv.8.html) for more information on the `sv` program.\n\n### Parameter Attributes\n\nThe first three parameters, `sv_dir`, `service_dir`, and `sv_bin` will attempt to use the corresponding node attributes, and fall back to hardcoded default values that match the settings used on Debian platform systems.\n\nMany of these parameters are only used in the `:enable` action.\n\n- **sv_dir** - The base \"service directory\" for the services managed by\n the resource. By default, this will attempt to use the\n `node['runit']['sv_dir']` attribute, and falls back to `/etc/sv`.\n- **service_dir** - The directory where services are symlinked to be\n supervised by `runsvdir`. By default, this will attempt to use the\n `node['runit']['service_dir']` attribute, and falls back to\n `/etc/service`.\n- **lsb_init_dir** - The directory where an LSB-compliant init script\n interface will be created. By default, this will attempt to use the\n `node['runit']['lsb_init_dir']` attribute, and falls back to\n `/etc/init.d`.\n- **sv_bin** - The path to the `sv` program binary. This will attempt\n to use the `node['runit']['sv_bin']` attribute, and falls back to\n `/usr/bin/sv`.\n- **service_name** - *Name attribute*. The name of the service. This\n will be used in the directory of the managed service in the\n `sv_dir` and `service_dir`.\n- **sv_timeout** - Override the default `sv` timeout of 7 seconds.\n- **sv_verbose** - Whether to enable `sv` verbose mode. Default is\n `false`.\n- **sv_templates** - If true, the `:enable` action will create the\n service directory with the appropriate templates. Default is\n `true`. Set this to `false` if the service has a package that\n provides its own service directory. See __Usage__ examples.\n- **options** - Options passed as variables to templates, for\n compatibility with legacy runit service definition. Default is an\n empty hash.\n- **env** - A hash of environment variables with their values as content\n used in the service's `env` directory. Default is an empty hash. When\n this hash is non-empty, the contents of the runit service's `env`\n directory will be managed by Chef in order to conform to the declared\n state.\n- **log** - Whether to start the service's logger with svlogd, requires\n a template `sv-service_name-log-run.erb` to configure the log's run\n script. Default is true.\n- **default_logger** - Whether a default `log/run` script should be set\n up. If true, the default content of the run script will use\n `svlogd` to write logs to `/var/log/service_name`. Default is false.\n- **log_dir** - The directory where the `svlogd` log service will run.\n Used when `default_logger` is `true`. Default is `/var/log/service_name`\n- **log_size** - The maximum size a log file can grow to before it is\n automatically rotated. See svlogd(8) for the default value.\n- **log_num** - The maximum number of log files that will be retained\n after rotation. See svlogd(8) for the default value.\n- **log_min** - The minimum number of log files that will be retained\n after rotation (if svlogd cannot create a new file and the minimum\n has not been reached, it will block). Default is no minimum.\n- **log_timeout** - The maximum age a log file can get to before it is\n automatically rotated, whether it has reached `log_size` or not.\n Default is no timeout.\n- **log_processor** - A string containing a path to a program that\n rotated log files will be fed through. See the **PROCESSOR** section\n of svlogd(8) for details. Default is no processor.\n- **log_socket** - An string containing an IP:port pair identifying a UDP\n socket that log lines will be copied to. Default is none.\n- **log_prefix** - A string that will be prepended to each line as it\n is logged. Default is no prefix.\n- **log_config_append** - A string containing optional additional lines to add\n to the log service configuration. See svlogd(8) for more details.\n- **cookbook** - A cookbook where templates are located instead of\n where the resource is used. Applies for all the templates in the\n `enable` action.\n- **check** - whether the service has a check script, requires a\n template `sv-service_name-check.erb`\n- **finish** - whether the service has a finish script, requires a\n template `sv-service_name-finish.erb`\n- **control** - An array of signals to customize control of the service,\n see [runsv man page](http://smarden.org/runit/runsv.8.html) on how\n to use this. This requires that each template be created with the\n name `sv-service_name-signal.erb`.\n- **owner** - user that should own the templates created to enable the\n service\n- **group** - group that should own the templates created to enable the\n service\n- **run_template_name** - alternate filename of the run run script to\n use replacing `service_name`.\n- **log_template_name** - alternate filename of the log run script to\n use replacing `service_name`.\n- **check_script_template_name** - alternate filename of the check\n script to use, replacing `service_name`.\n- **finish_script_template_name** - alternate filename of the finish\n script to use, replacing `service_name`.\n- **control_template_names** - a hash of control signals (see *control*\n above) and their alternate template name(s) replacing\n `service_name`.\n- **status_command** - The command used to check the status of the\n service to see if it is enabled/running (if it's running, it's\n enabled). This hardcodes the location of the sv program to\n `/usr/bin/sv` due to the aforementioned cookbook load order.\n- **restart_on_update** - Whether the service should be restarted when\n the run script is updated. Defaults to `true`. Set to `false` if\n the service shouldn't be restarted when the run script is updated.\n- **start_down** - Set the default state of the runit service to 'down' by creating\n `<sv_dir>/down` file\n- **delete_downfile** - Delete previously created `<sv_dir>/down` file\n\nUnlike previous versions of the cookbook using the `runit_service` definition, the `runit_service` resource can be notified. See __Usage__ examples below.\n\n\nUsage\n-----\nTo get runit installed on supported platforms, use `recipe[runit]`. Once it is installed, use the `runit_service` resource to set up services to be managed by runit.\n\nIn order to use the `runit_service` resource in your cookbook(s), each service managed will also need to have `sv-service_name-run.erb` and `sv-service_name-log-run.erb` templates created. If the `log` parameter is false, the log run script isn't created. If the `log` parameter is true, and `default_logger` is also true, the log run\nscript will be created with the default content:\n\n```bash\n#!/bin/sh\nexec svlogd -tt /var/log/service_name\n```\n\n### Examples\nThese are example use cases of the `runit_service` resource described above. There are others in the `runit_test` cookbook that is included in the [git repository](https://github.com/hw-cookbooks/runit).\n\n**Default Example**\n\nThis example uses all the defaults in the `:enable` action to set up the service.\n\nWe'll set up `chef-client` to run as a service under runit, such as is done in the `chef-client` cookbook. This example will be more simple than in that cookbook. First, create the required run template, `chef-client/templates/default/sv-chef-client-run.erb`.\n\n```bash\n#!/bin/sh\nexec 2>&1\nexec /usr/bin/env chef-client -i 1800 -s 30\n```\n\nThen create the required log/run template, `chef-client/templates/default/sv-chef-client-log-run.erb`.\n\n```bash\n#!/bin/sh\nexec svlogd -tt ./main\n```\n\n__Note__ This will cause output of the running process to go to `/etc/sv/chef-client/log/main/current`. Some people may not like this, see the following example. This is preserved for compatibility reasons.\n\nFinally, set up the service in the recipe with:\n\n```ruby\nrunit_service \"chef-client\"\n```\n\n**Default Logger Example**\n\nTo use a default logger with svlogd which will log to `/var/log/chef-client/current`, instead, use the `default_logger` option.\n\n```ruby\nrunit_service \"chef-client\" do\n default_logger true\nend\n```\n\n**No Log Service**\n\nIf there isn't an appendant log service, set `log` to false, and the log/run script won't be created.\n\n```ruby\nrunit_service \"no-svlog\" do\n log false\nend\n```\n\n**Check Script**\n\nTo create a service that has a check script in its service directory, set the `check` parameter to `true`, and create a `sv-checker-check.erb` template.\n\n```ruby\nrunit_service \"checker\" do\n check true\nend\n```\n\nThis will create `/etc/sv/checker/check`.\n\n**Finish Script**\n\nTo create a service that has a finish script in its service directory, set the `finish` parameter to `true`, and create a `sv-finisher-finish.erb` template.\n\n```ruby\nrunit_service \"finisher\" do\n finish true\nend\n```\n\nThis will create `/etc/sv/finisher/finish`.\n\n**Alternate service directory**\n\nIf the service directory for the managed service isn't the `sv_dir` (`/etc/sv`), then specify it:\n\n```ruby\nrunit_service \"custom_service\" do\n sv_dir \"/etc/custom_service/runit\"\nend\n```\n\n**No Service Directory**\n\nIf the service to manage has a package that provides its service directory, such as `git-daemon` on Debian systems, set `sv_templates` to false.\n\n```ruby\npackage \"git-daemon-run\"\n\nrunit_service \"git-daemon\" do\n sv_templates false\nend\n```\n\nThis will create the service symlink in `/etc/service`, but it will not manage any templates in the service directory.\n\n**User Controlled Services**\n\nTo set up services controlled by a non-privileged user, we follow the recommended configuration in the [runit documentation](http://smarden.org/runit/faq.html#user) (Is it possible to allow a user other than root to control a service?).\n\nSuppose the user's name is floyd, and floyd wants to run floyds-app. Assuming that the floyd user and group are already managed with Chef, create a `runsvdir-floyd` runit_service.\n\n```ruby\nrunit_service \"runsvdir-floyd\"\n```\n\nCreate the `sv-runsvdir-floyd-log-run.erb` template, or add `log false`. Also create the `sv-runsvdir-floyd-run.erb` with the following content:\n\n```bash\n#!/bin/sh\nexec 2>&1\nexec chpst -ufloyd runsvdir /home/floyd/service\n```\n\nNext, create the `runit_service` resource for floyd's app:\n\n```ruby\nrunit_service \"floyds-app\" do\n sv_dir \"/home/floyd/sv\"\n service_dir \"/home/floyd/service\"\n owner \"floyd\"\n group \"floyd\"\nend\n```\n\nAnd now floyd can manage the service with sv:\n\n```text\n$ id\nuid=1000(floyd) gid=1001(floyd) groups=1001(floyd)\n$ sv stop /home/floyd/service/floyds-app/\nok: down: /home/floyd/service/floyds-app/: 0s, normally up\n$ sv start /home/floyd/service/floyds-app/\nok: run: /home/floyd/service/floyds-app/: (pid 5287) 0s\n$ sv status /home/floyd/service/floyds-app/\nrun: /home/floyd/service/floyds-app/: (pid 5287) 13s; run: log: (pid 4691) 726s\n```\n\n**Options**\n\nNext, let's set up memcached under runit with some additional options using the `options` parameter. First, the `memcached/templates/default/sv-memcached-run.erb` template:\n\n```bash\n#!/bin/sh\nexec 2>&1\nexec chpst -u <%= @options[:user] %> /usr/bin/memcached -v -m <%= @options[:memory] %> -p <%= @options[:port] %>\n```\n\nNote that the script uses `chpst` (which comes with runit) to set the user option, then starts memcached on the specified memory and port (see below).\n\nThe log/run template, `memcached/templates/default/sv-memcached-log-run.erb`:\n\n```bash\n#!/bin/sh\nexec svlogd -tt ./main\n```\n\nFinally, the `runit_service` in our recipe:\n\n```ruby\nrunit_service \"memcached\" do\n options({\n :memory => node[:memcached][:memory],\n :port => node[:memcached][:port],\n :user => node[:memcached][:user]\n }.merge(params))\nend\n```\n\nThis is where the user, port and memory options used in the run template are used.\n\n**Notifying Runit Services**\n\nIn previous versions of this cookbook where the definition was used, it created a `service` resource that could be notified. With the `runit_service` resource, recipes need to use the full resource name.\n\nFor example:\n\n```ruby\nrunit_service \"my-service\"\n\ntemplate \"/etc/my-service.conf\" do\n notifies :restart, \"runit_service[my-service]\"\nend\n```\n\nBecause the resource implements actions for various commands that `sv` can send to the service, any of those actions could be used for notification. For example, `chef-client` supports triggering a Chef run with a USR1 signal.\n\n```ruby\ntemplate \"/tmp/chef-notifier\" do\n notifies :usr1, \"runit_service[chef-client]\"\nend\n```\n\nFor older implementations of services that used `runit_service` as a definition, but may support alternate service styles, use a conditional, such as based on an attribute:\n\n```ruby\nservice_to_notify = case node['nginx']['init_style']\n when \"runit\"\n \"runit_service[nginx]\"\n else\n \"service[nginx]\"\n end\n\ntemplate \"/etc/nginx/nginx.conf\" do\n notifies :restart, service_to_notify\nend\n```\n\n**More Examples**\n\nFor more examples, see the `runit_test` cookbook's `service` recipe in the [git repository](https://github.com/hw-cookbooks/runit).\n\n\nLicense & Authors\n-----------------\n- Author:: Adam Jacob <adam@chef.io>\n- Author:: Joshua Timberman <joshua@chef.io>\n- Author:: Sean OMeara <sean@chef.io>\n\n```text\nCopyright:: 2008-2016, Chef Software, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
|
5
|
+
"maintainer": "Heavy Water Operations, LLC.",
|
6
|
+
"maintainer_email": "support@hw-ops.com",
|
7
|
+
"license": "Apache 2.0",
|
8
|
+
"platforms": {
|
9
|
+
"ubuntu": ">= 0.0.0",
|
10
|
+
"debian": ">= 0.0.0",
|
11
|
+
"gentoo": ">= 0.0.0",
|
12
|
+
"centos": ">= 0.0.0",
|
13
|
+
"redhat": ">= 0.0.0",
|
14
|
+
"amazon": ">= 0.0.0",
|
15
|
+
"scientific": ">= 0.0.0",
|
16
|
+
"oracle": ">= 0.0.0",
|
17
|
+
"enterpriseenterprise": ">= 0.0.0"
|
18
|
+
},
|
19
|
+
"dependencies": {
|
20
|
+
"packagecloud": ">= 0.0.0"
|
21
|
+
},
|
22
|
+
"recommendations": {
|
23
|
+
|
24
|
+
},
|
25
|
+
"suggestions": {
|
26
|
+
|
27
|
+
},
|
28
|
+
"conflicting": {
|
29
|
+
|
30
|
+
},
|
31
|
+
"providing": {
|
32
|
+
|
33
|
+
},
|
34
|
+
"replacing": {
|
35
|
+
|
36
|
+
},
|
37
|
+
"attributes": {
|
38
|
+
|
39
|
+
},
|
40
|
+
"groupings": {
|
41
|
+
|
42
|
+
},
|
43
|
+
"recipes": {
|
44
|
+
"runit": "Installs and configures runit"
|
45
|
+
},
|
46
|
+
"version": "1.7.4",
|
47
|
+
"source_url": "",
|
48
|
+
"issues_url": "",
|
49
|
+
"privacy": false
|
50
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: runit
|
3
|
+
# Recipe:: default
|
4
|
+
#
|
5
|
+
# Copyright 2008-2010, Chef Software, Inc.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
service 'runit' do
|
21
|
+
action :nothing
|
22
|
+
end
|
23
|
+
|
24
|
+
execute 'start-runsvdir' do
|
25
|
+
command value_for_platform(
|
26
|
+
'debian' => { 'default' => 'runsvdir-start' },
|
27
|
+
'ubuntu' => { 'default' => 'start runsvdir' },
|
28
|
+
'gentoo' => { 'default' => '/etc/init.d/runit-start start' }
|
29
|
+
)
|
30
|
+
action :nothing
|
31
|
+
end
|
32
|
+
|
33
|
+
execute 'runit-hup-init' do
|
34
|
+
command 'telinit q'
|
35
|
+
only_if 'grep ^SV /etc/inittab'
|
36
|
+
action :nothing
|
37
|
+
end
|
38
|
+
|
39
|
+
case node['platform_family']
|
40
|
+
when 'rhel', 'fedora'
|
41
|
+
|
42
|
+
packagecloud_repo 'imeyer/runit' unless node['runit']['prefer_local_yum']
|
43
|
+
package 'runit'
|
44
|
+
|
45
|
+
if node['platform_version'].to_i == 7
|
46
|
+
service 'runsvdir-start' do
|
47
|
+
action [:start, :enable]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
when 'debian', 'gentoo'
|
52
|
+
|
53
|
+
if platform?('gentoo')
|
54
|
+
template '/etc/init.d/runit-start' do
|
55
|
+
source 'runit-start.sh.erb'
|
56
|
+
mode 0755
|
57
|
+
end
|
58
|
+
|
59
|
+
service 'runit-start' do
|
60
|
+
action :nothing
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
package 'runit' do
|
65
|
+
action :install
|
66
|
+
response_file 'runit.seed' if platform?('ubuntu', 'debian')
|
67
|
+
notifies value_for_platform(
|
68
|
+
'debian' => { '4.0' => :run, 'default' => :nothing },
|
69
|
+
'ubuntu' => {
|
70
|
+
'default' => :nothing,
|
71
|
+
'9.04' => :run,
|
72
|
+
'8.10' => :run,
|
73
|
+
'8.04' => :run },
|
74
|
+
'gentoo' => { 'default' => :run }
|
75
|
+
), 'execute[start-runsvdir]', :immediately
|
76
|
+
notifies value_for_platform(
|
77
|
+
'debian' => { 'squeeze/sid' => :run, 'default' => :nothing },
|
78
|
+
'default' => :nothing
|
79
|
+
), 'execute[runit-hup-init]', :immediately
|
80
|
+
notifies :enable, 'service[runit-start]' if platform?('gentoo')
|
81
|
+
end
|
82
|
+
|
83
|
+
if node['platform'] =~ /ubuntu/i && node['platform_version'].to_f <= 8.04
|
84
|
+
cookbook_file '/etc/event.d/runsvdir' do
|
85
|
+
source 'runsvdir'
|
86
|
+
mode 0644
|
87
|
+
notifies :run, 'execute[start-runsvdir]', :immediately
|
88
|
+
only_if { ::File.directory?('/etc/event.d') }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: <%= @name %>
|
4
|
+
# Required-Start:
|
5
|
+
# Required-Stop:
|
6
|
+
# Default-Start:
|
7
|
+
# Default-Stop:
|
8
|
+
# Short-Description: initscript for runit-managed <%= @name %> service
|
9
|
+
### END INIT INFO
|
10
|
+
|
11
|
+
# Author: Chef Software, Inc. <cookbooks@chef.io>
|
12
|
+
|
13
|
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
14
|
+
DESC="runit-managed <%= @name %>"
|
15
|
+
NAME=<%= @name %>
|
16
|
+
RUNIT=<%= @sv_bin %>
|
17
|
+
SCRIPTNAME=<%= @init_dir %>$NAME
|
18
|
+
|
19
|
+
# Exit if runit is not installed
|
20
|
+
[ -x $RUNIT ] || exit 0
|
21
|
+
|
22
|
+
# Load the VERBOSE setting and other rcS variables
|
23
|
+
. /lib/init/vars.sh
|
24
|
+
|
25
|
+
# Define LSB log_* functions.
|
26
|
+
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
27
|
+
. /lib/lsb/init-functions
|
28
|
+
|
29
|
+
|
30
|
+
case "$1" in
|
31
|
+
start)
|
32
|
+
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
|
33
|
+
$RUNIT start $NAME
|
34
|
+
[ "$VERBOSE" != no ] && log_end_msg $?
|
35
|
+
;;
|
36
|
+
stop)
|
37
|
+
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
38
|
+
$RUNIT stop $NAME
|
39
|
+
[ "$VERBOSE" != no ] && log_end_msg $?
|
40
|
+
;;
|
41
|
+
status)
|
42
|
+
$RUNIT status $NAME && exit 0 || exit $?
|
43
|
+
;;
|
44
|
+
reload)
|
45
|
+
[ "$VERBOSE" != no ] && log_daemon_msg "Reloading $DESC" "$NAME"
|
46
|
+
$RUNIT reload $NAME
|
47
|
+
[ "$VERBOSE" != no ] && log_end_msg $?
|
48
|
+
;;
|
49
|
+
force-reload)
|
50
|
+
[ "$VERBOSE" != no ] && log_daemon_msg "Force reloading $DESC" "$NAME"
|
51
|
+
$RUNIT force-reload $NAME
|
52
|
+
[ "$VERBOSE" != no ] && log_end_msg $?
|
53
|
+
;;
|
54
|
+
restart)
|
55
|
+
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
|
56
|
+
$RUNIT restart $NAME
|
57
|
+
[ "$VERBOSE" != no ] && log_end_msg $?
|
58
|
+
;;
|
59
|
+
*)
|
60
|
+
echo "Usage: $SCRIPTNAME {start|stop|status|reload|force-reload|restart}" >&2
|
61
|
+
exit 3
|
62
|
+
;;
|
63
|
+
esac
|
64
|
+
|
65
|
+
:
|
66
|
+
|