microwave 0.1004.4 → 0.1004.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -3
- data/lib/chef/client.rb +2 -11
- data/lib/chef/platform.rb +1 -192
- data/lib/chef/providers.rb +0 -68
- data/lib/chef/resources.rb +0 -36
- data/lib/chef/version.rb +1 -1
- metadata +123 -239
- data/lib/chef/provider/breakpoint.rb +0 -31
- data/lib/chef/provider/cron.rb +0 -186
- data/lib/chef/provider/cron/solaris.rb +0 -195
- data/lib/chef/provider/deploy.rb +0 -343
- data/lib/chef/provider/deploy/revision.rb +0 -80
- data/lib/chef/provider/deploy/timestamped.rb +0 -33
- data/lib/chef/provider/env.rb +0 -152
- data/lib/chef/provider/env/windows.rb +0 -75
- data/lib/chef/provider/erl_call.rb +0 -101
- data/lib/chef/provider/git.rb +0 -243
- data/lib/chef/provider/group.rb +0 -133
- data/lib/chef/provider/group/aix.rb +0 -70
- data/lib/chef/provider/group/dscl.rb +0 -121
- data/lib/chef/provider/group/gpasswd.rb +0 -53
- data/lib/chef/provider/group/groupadd.rb +0 -81
- data/lib/chef/provider/group/pw.rb +0 -84
- data/lib/chef/provider/group/suse.rb +0 -53
- data/lib/chef/provider/group/usermod.rb +0 -57
- data/lib/chef/provider/group/windows.rb +0 -79
- data/lib/chef/provider/ifconfig.rb +0 -134
- data/lib/chef/provider/log.rb +0 -54
- data/lib/chef/provider/mdadm.rb +0 -91
- data/lib/chef/provider/mount.rb +0 -114
- data/lib/chef/provider/mount/mount.rb +0 -240
- data/lib/chef/provider/mount/windows.rb +0 -81
- data/lib/chef/provider/ohai.rb +0 -42
- data/lib/chef/provider/package.rb +0 -163
- data/lib/chef/provider/package/apt.rb +0 -135
- data/lib/chef/provider/package/dpkg.rb +0 -115
- data/lib/chef/provider/package/easy_install.rb +0 -136
- data/lib/chef/provider/package/freebsd.rb +0 -125
- data/lib/chef/provider/package/macports.rb +0 -105
- data/lib/chef/provider/package/pacman.rb +0 -101
- data/lib/chef/provider/package/portage.rb +0 -135
- data/lib/chef/provider/package/rpm.rb +0 -104
- data/lib/chef/provider/package/rubygems.rb +0 -465
- data/lib/chef/provider/package/solaris.rb +0 -130
- data/lib/chef/provider/package/yum.rb +0 -1128
- data/lib/chef/provider/package/zypper.rb +0 -144
- data/lib/chef/provider/route.rb +0 -193
- data/lib/chef/provider/ruby_block.rb +0 -34
- data/lib/chef/provider/script.rb +0 -55
- data/lib/chef/provider/service.rb +0 -122
- data/lib/chef/provider/service/arch.rb +0 -116
- data/lib/chef/provider/service/debian.rb +0 -130
- data/lib/chef/provider/service/freebsd.rb +0 -154
- data/lib/chef/provider/service/gentoo.rb +0 -53
- data/lib/chef/provider/service/init.rb +0 -71
- data/lib/chef/provider/service/insserv.rb +0 -52
- data/lib/chef/provider/service/redhat.rb +0 -60
- data/lib/chef/provider/service/simple.rb +0 -120
- data/lib/chef/provider/service/solaris.rb +0 -85
- data/lib/chef/provider/service/systemd.rb +0 -102
- data/lib/chef/provider/service/upstart.rb +0 -198
- data/lib/chef/provider/service/windows.rb +0 -146
- data/lib/chef/provider/subversion.rb +0 -197
- data/lib/chef/provider/user.rb +0 -186
- data/lib/chef/provider/user/dscl.rb +0 -280
- data/lib/chef/provider/user/pw.rb +0 -113
- data/lib/chef/provider/user/useradd.rb +0 -137
- data/lib/chef/provider/user/windows.rb +0 -124
- data/lib/chef/resource/apt_package.rb +0 -34
- data/lib/chef/resource/bash.rb +0 -33
- data/lib/chef/resource/breakpoint.rb +0 -35
- data/lib/chef/resource/cron.rb +0 -188
- data/lib/chef/resource/csh.rb +0 -33
- data/lib/chef/resource/deploy.rb +0 -380
- data/lib/chef/resource/deploy_revision.rb +0 -40
- data/lib/chef/resource/dpkg_package.rb +0 -34
- data/lib/chef/resource/easy_install_package.rb +0 -57
- data/lib/chef/resource/erl_call.rb +0 -83
- data/lib/chef/resource/freebsd_package.rb +0 -35
- data/lib/chef/resource/gem_package.rb +0 -53
- data/lib/chef/resource/git.rb +0 -46
- data/lib/chef/resource/group.rb +0 -70
- data/lib/chef/resource/ifconfig.rb +0 -134
- data/lib/chef/resource/log.rb +0 -62
- data/lib/chef/resource/macports_package.rb +0 -29
- data/lib/chef/resource/mdadm.rb +0 -82
- data/lib/chef/resource/mount.rb +0 -134
- data/lib/chef/resource/ohai.rb +0 -40
- data/lib/chef/resource/package.rb +0 -80
- data/lib/chef/resource/pacman_package.rb +0 -33
- data/lib/chef/resource/perl.rb +0 -33
- data/lib/chef/resource/portage_package.rb +0 -33
- data/lib/chef/resource/python.rb +0 -33
- data/lib/chef/resource/route.rb +0 -135
- data/lib/chef/resource/rpm_package.rb +0 -34
- data/lib/chef/resource/ruby.rb +0 -33
- data/lib/chef/resource/ruby_block.rb +0 -40
- data/lib/chef/resource/scm.rb +0 -147
- data/lib/chef/resource/script.rb +0 -60
- data/lib/chef/resource/service.rb +0 -160
- data/lib/chef/resource/solaris_package.rb +0 -36
- data/lib/chef/resource/subversion.rb +0 -36
- data/lib/chef/resource/timestamped_deploy.rb +0 -31
- data/lib/chef/resource/user.rb +0 -130
- data/lib/chef/resource/yum_package.rb +0 -63
@@ -1,116 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Jan Zimmek (<jan.zimmek@web.de>)
|
3
|
-
# Copyright:: Copyright (c) 2010 Jan Zimmek
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service/init'
|
20
|
-
require 'chef/mixin/command'
|
21
|
-
|
22
|
-
class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
23
|
-
|
24
|
-
def initialize(new_resource, run_context)
|
25
|
-
super
|
26
|
-
@init_command = "/etc/rc.d/#{@new_resource.service_name}"
|
27
|
-
end
|
28
|
-
|
29
|
-
def load_current_resource
|
30
|
-
|
31
|
-
raise Chef::Exceptions::Service unless ::File.exists?("/etc/rc.conf")
|
32
|
-
raise Chef::Exceptions::Service unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
|
33
|
-
|
34
|
-
super
|
35
|
-
|
36
|
-
@current_resource.enabled(daemons.include?(@current_resource.service_name))
|
37
|
-
|
38
|
-
@current_resource
|
39
|
-
end
|
40
|
-
|
41
|
-
# Get list of all daemons from the file '/etc/rc.conf'.
|
42
|
-
# Mutiple lines and background form are supported. Example:
|
43
|
-
# DAEMONS=(\
|
44
|
-
# foobar \
|
45
|
-
# @example \
|
46
|
-
# !net \
|
47
|
-
# )
|
48
|
-
def daemons
|
49
|
-
entries = []
|
50
|
-
if ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
|
51
|
-
entries += $1.gsub(/\\?[\r\n]/, ' ').gsub(/# *[^ ]+/,' ').split(' ') if $1.length > 0
|
52
|
-
end
|
53
|
-
|
54
|
-
yield(entries) if block_given?
|
55
|
-
|
56
|
-
entries
|
57
|
-
end
|
58
|
-
|
59
|
-
# FIXME: Multiple entries of DAEMONS will cause very bad results :)
|
60
|
-
def update_daemons(entries)
|
61
|
-
content = ::File.read("/etc/rc.conf").gsub(/DAEMONS=\((.*)\)/m, "DAEMONS=(#{entries.join(' ')})")
|
62
|
-
::File.open("/etc/rc.conf", "w") do |f|
|
63
|
-
f.write(content)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def enable_service()
|
68
|
-
new_daemons = []
|
69
|
-
entries = daemons
|
70
|
-
|
71
|
-
if entries.include?(new_resource.service_name) or entries.include?("@#{new_resource.service_name}")
|
72
|
-
# exists and already enabled (or already enabled as a background service)
|
73
|
-
# new_daemons += entries
|
74
|
-
else
|
75
|
-
if entries.include?("!#{new_resource.service_name}")
|
76
|
-
# exists but disabled
|
77
|
-
entries.each do |daemon|
|
78
|
-
if daemon == "!#{new_resource.service_name}"
|
79
|
-
new_daemons << new_resource.service_name
|
80
|
-
else
|
81
|
-
new_daemons << daemon
|
82
|
-
end
|
83
|
-
end
|
84
|
-
else
|
85
|
-
# does not exist
|
86
|
-
new_daemons += entries
|
87
|
-
new_daemons << new_resource.service_name
|
88
|
-
end
|
89
|
-
update_daemons(new_daemons)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def disable_service()
|
94
|
-
new_daemons = []
|
95
|
-
entries = daemons
|
96
|
-
|
97
|
-
if entries.include?("!#{new_resource.service_name}")
|
98
|
-
# exists and disabled
|
99
|
-
# new_daemons += entries
|
100
|
-
else
|
101
|
-
if entries.include?(new_resource.service_name) or entries.include?("@#{new_resource.service_name}")
|
102
|
-
# exists but enabled (or enabled as a back-ground service)
|
103
|
-
# FIXME: Does arch support !@foobar ?
|
104
|
-
entries.each do |daemon|
|
105
|
-
if [new_resource.service_name, "@#{new_resource.service_name}"].include?(daemon)
|
106
|
-
new_daemons << "!#{new_resource.service_name}"
|
107
|
-
else
|
108
|
-
new_daemons << daemon
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
update_daemons(new_daemons)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: AJ Christensen (<aj@hjksolutions.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service'
|
20
|
-
require 'chef/provider/service/init'
|
21
|
-
require 'chef/mixin/command'
|
22
|
-
|
23
|
-
class Chef
|
24
|
-
class Provider
|
25
|
-
class Service
|
26
|
-
class Debian < Chef::Provider::Service::Init
|
27
|
-
UPDATE_RC_D_ENABLED_MATCHES = /\/rc[\dS].d\/S|not installed/i
|
28
|
-
UPDATE_RC_D_PRIORITIES = /\/rc([\dS]).d\/([SK])(\d\d)/i
|
29
|
-
|
30
|
-
def load_current_resource
|
31
|
-
super
|
32
|
-
|
33
|
-
@current_resource.priority(get_priority)
|
34
|
-
@current_resource.enabled(service_currently_enabled?(@current_resource.priority))
|
35
|
-
@current_resource
|
36
|
-
end
|
37
|
-
|
38
|
-
def assert_update_rcd_available
|
39
|
-
unless ::File.exists? "/usr/sbin/update-rc.d"
|
40
|
-
raise Chef::Exceptions::Service, "/usr/sbin/update-rc.d does not exist!"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def get_priority
|
45
|
-
assert_update_rcd_available
|
46
|
-
priority = {}
|
47
|
-
|
48
|
-
status = popen4("/usr/sbin/update-rc.d -n -f #{@current_resource.service_name} remove") do |pid, stdin, stdout, stderr|
|
49
|
-
|
50
|
-
[stdout, stderr].each do |iop|
|
51
|
-
iop.each_line do |line|
|
52
|
-
if UPDATE_RC_D_PRIORITIES =~ line
|
53
|
-
# priority[runlevel] = [ S|K, priority ]
|
54
|
-
# S = Start, K = Kill
|
55
|
-
# debian runlevels: 0 Halt, 1 Singleuser, 2 Multiuser, 3-5 == 2, 6 Reboot
|
56
|
-
priority[$1] = [($2 == "S" ? :start : :stop), $3]
|
57
|
-
end
|
58
|
-
if line =~ UPDATE_RC_D_ENABLED_MATCHES
|
59
|
-
enabled = true
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
unless status.exitstatus == 0
|
66
|
-
raise Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{@current_resource.service_name} failed - #{status.inspect}"
|
67
|
-
end
|
68
|
-
priority
|
69
|
-
end
|
70
|
-
|
71
|
-
def service_currently_enabled?(priority)
|
72
|
-
enabled = false
|
73
|
-
|
74
|
-
priority.each { |runlevel, arguments|
|
75
|
-
Chef::Log.debug("#{@new_resource} runlevel #{runlevel}, action #{arguments[0]}, priority #{arguments[1]}")
|
76
|
-
|
77
|
-
# if we are in a update-rc.d default startup runlevel && we start in this runlevel
|
78
|
-
if (2..5).include?(runlevel.to_i) && arguments[0] == :start
|
79
|
-
enabled = true
|
80
|
-
end
|
81
|
-
}
|
82
|
-
|
83
|
-
enabled
|
84
|
-
end
|
85
|
-
|
86
|
-
def enable_service()
|
87
|
-
if @new_resource.priority.is_a? Integer
|
88
|
-
run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
|
89
|
-
run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults #{@new_resource.priority} #{100 - @new_resource.priority}")
|
90
|
-
elsif @new_resource.priority.is_a? Hash
|
91
|
-
# we call the same command regardless of we're enabling or disabling
|
92
|
-
# users passing a Hash are responsible for setting their own start priorities
|
93
|
-
set_priority()
|
94
|
-
else # No priority, go with update-rc.d defaults
|
95
|
-
run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
|
96
|
-
run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults")
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
def disable_service()
|
102
|
-
if @new_resource.priority.is_a? Integer
|
103
|
-
# Stop processes in reverse order of start using '100 - start_priority'
|
104
|
-
run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
|
105
|
-
run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop #{100 - @new_resource.priority} 2 3 4 5 .")
|
106
|
-
elsif @new_resource.priority.is_a? Hash
|
107
|
-
# we call the same command regardless of we're enabling or disabling
|
108
|
-
# users passing a Hash are responsible for setting their own stop priorities
|
109
|
-
set_priority()
|
110
|
-
else
|
111
|
-
# no priority, using '100 - 20 (update-rc.d default)' to stop in reverse order of start
|
112
|
-
run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
|
113
|
-
run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop 80 2 3 4 5 .")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def set_priority()
|
118
|
-
args = ""
|
119
|
-
@new_resource.priority.each do |level, o|
|
120
|
-
action = o[0]
|
121
|
-
priority = o[1]
|
122
|
-
args += "#{action} #{priority} #{level} . "
|
123
|
-
end
|
124
|
-
run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove")
|
125
|
-
run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} #{args}")
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
@@ -1,154 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
-
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/provider/service'
|
20
|
-
require 'chef/mixin/command'
|
21
|
-
|
22
|
-
class Chef
|
23
|
-
class Provider
|
24
|
-
class Service
|
25
|
-
class Freebsd < Chef::Provider::Service::Init
|
26
|
-
|
27
|
-
def load_current_resource
|
28
|
-
@current_resource = Chef::Resource::Service.new(@new_resource.name)
|
29
|
-
@current_resource.service_name(@new_resource.service_name)
|
30
|
-
|
31
|
-
# Determine if we're talking about /etc/rc.d or /usr/local/etc/rc.d
|
32
|
-
if ::File.exists?("/etc/rc.d/#{current_resource.service_name}")
|
33
|
-
@init_command = "/etc/rc.d/#{current_resource.service_name}"
|
34
|
-
elsif ::File.exists?("/usr/local/etc/rc.d/#{current_resource.service_name}")
|
35
|
-
@init_command = "/usr/local/etc/rc.d/#{current_resource.service_name}"
|
36
|
-
else
|
37
|
-
raise Chef::Exceptions::Service, "#{@new_resource}: unable to locate the rc.d script"
|
38
|
-
end
|
39
|
-
Chef::Log.debug("#{@current_resource} found at #{@init_command}")
|
40
|
-
|
41
|
-
if @new_resource.supports[:status]
|
42
|
-
begin
|
43
|
-
if run_command(:command => "#{@init_command} status") == 0
|
44
|
-
@current_resource.running true
|
45
|
-
Chef::Log.debug("#{@new_resource} is running")
|
46
|
-
end
|
47
|
-
rescue Chef::Exceptions::Exec
|
48
|
-
@current_resource.running false
|
49
|
-
nil
|
50
|
-
end
|
51
|
-
|
52
|
-
elsif @new_resource.status_command
|
53
|
-
begin
|
54
|
-
if run_command(:command => @new_resource.status_command) == 0
|
55
|
-
@current_resource.running true
|
56
|
-
Chef::Log.debug("#{@new_resource} is running")
|
57
|
-
end
|
58
|
-
rescue Chef::Exceptions::Exec
|
59
|
-
@current_resource.running false
|
60
|
-
nil
|
61
|
-
end
|
62
|
-
|
63
|
-
else
|
64
|
-
Chef::Log.debug("#{@new_resource} does not support status and you have not specified a status command, falling back to process table inspection")
|
65
|
-
|
66
|
-
if node[:command][:ps].nil? or node[:command][:ps].empty?
|
67
|
-
raise Chef::Exceptions::Service, "#{@new_resource} could not determine how to inspect the process table, please set this nodes 'ps' attribute"
|
68
|
-
end
|
69
|
-
|
70
|
-
status = popen4(node[:command][:ps]) do |pid, stdin, stdout, stderr|
|
71
|
-
r = Regexp.new(@new_resource.pattern)
|
72
|
-
Chef::Log.debug("#{@new_resource} attempting to match #{@new_resource.pattern} (#{r}) against process table")
|
73
|
-
stdout.each_line do |line|
|
74
|
-
if r.match(line)
|
75
|
-
@current_resource.running true
|
76
|
-
break
|
77
|
-
end
|
78
|
-
end
|
79
|
-
@current_resource.running false unless @current_resource.running
|
80
|
-
end
|
81
|
-
unless status.exitstatus == 0
|
82
|
-
raise Chef::Exceptions::Service, "Command #{node[:command][:ps]} failed"
|
83
|
-
else
|
84
|
-
Chef::Log.debug("#{@new_resource} #{node[:command][:ps]} exited and parsed successfully, process running: #{@current_resource.running}")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
if ::File.exists?("/etc/rc.conf")
|
89
|
-
read_rc_conf.each do |line|
|
90
|
-
case line
|
91
|
-
when /#{Regexp.escape(service_enable_variable_name)}="(\w+)"/
|
92
|
-
if $1 =~ /[Yy][Ee][Ss]/
|
93
|
-
@current_resource.enabled true
|
94
|
-
elsif $1 =~ /[Nn][Oo][Nn]?[Oo]?[Nn]?[Ee]?/
|
95
|
-
@current_resource.enabled false
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
unless @current_resource.enabled
|
101
|
-
Chef::Log.debug("#{@new_resource.name} enable/disable state unknown")
|
102
|
-
end
|
103
|
-
|
104
|
-
@current_resource
|
105
|
-
end
|
106
|
-
|
107
|
-
def read_rc_conf
|
108
|
-
::File.open("/etc/rc.conf", 'r') { |file| file.readlines }
|
109
|
-
end
|
110
|
-
|
111
|
-
def write_rc_conf(lines)
|
112
|
-
::File.open("/etc/rc.conf", 'w') do |file|
|
113
|
-
lines.each { |line| file.puts(line) }
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
|
118
|
-
# The variable name used in /etc/rc.conf for enabling this service
|
119
|
-
def service_enable_variable_name
|
120
|
-
# Look for name="foo" in the shell script @init_command. Use this for determining the variable name in /etc/rc.conf
|
121
|
-
# corresponding to this service
|
122
|
-
# For example: to enable the service mysql-server with the init command /usr/local/etc/rc.d/mysql-server, you need
|
123
|
-
# to set mysql_enable="YES" in /etc/rc.conf
|
124
|
-
makefile = ::File.open(@init_command)
|
125
|
-
makefile.each do |line|
|
126
|
-
case line
|
127
|
-
when /^name="?(\w+)"?/
|
128
|
-
return $1 + "_enable"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
raise Chef::Exceptions::Service, "Could not find name=\"service\" line in #{@init_command}"
|
132
|
-
end
|
133
|
-
|
134
|
-
def set_service_enable(value)
|
135
|
-
lines = read_rc_conf
|
136
|
-
# Remove line that set the old value
|
137
|
-
lines.delete_if { |line| line =~ /#{service_enable_variable_name}/ }
|
138
|
-
# And append the line that sets the new value at the end
|
139
|
-
lines << "#{service_enable_variable_name}=\"#{value}\""
|
140
|
-
write_rc_conf(lines)
|
141
|
-
end
|
142
|
-
|
143
|
-
def enable_service()
|
144
|
-
set_service_enable("YES") unless @current_resource.enabled
|
145
|
-
end
|
146
|
-
|
147
|
-
def disable_service()
|
148
|
-
set_service_enable("NO") if @current_resource.enabled
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Lee Jensen (<ljensen@engineyard.com>)
|
3
|
-
# Author:: AJ Christensen (<aj@opscode.com>)
|
4
|
-
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
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
|
-
require 'chef/provider/service'
|
21
|
-
require 'chef/mixin/command'
|
22
|
-
|
23
|
-
class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
24
|
-
def load_current_resource
|
25
|
-
|
26
|
-
@new_resource.supports[:status] = true
|
27
|
-
@new_resource.supports[:restart] = true
|
28
|
-
|
29
|
-
super
|
30
|
-
|
31
|
-
raise Chef::Exceptions::Service unless ::File.exists?("/sbin/rc-update")
|
32
|
-
|
33
|
-
@current_resource.enabled(
|
34
|
-
Dir.glob("/etc/runlevels/**/#{@current_resource.service_name}").any? do |file|
|
35
|
-
exists = ::File.exists? file
|
36
|
-
readable = ::File.readable? file
|
37
|
-
Chef::Log.debug "#{@new_resource} exists: #{exists}, readable: #{readable}"
|
38
|
-
exists and readable
|
39
|
-
end
|
40
|
-
)
|
41
|
-
Chef::Log.debug "#{@new_resource} enabled: #{@current_resource.enabled}"
|
42
|
-
|
43
|
-
@current_resource
|
44
|
-
end
|
45
|
-
|
46
|
-
def enable_service()
|
47
|
-
run_command(:command => "/sbin/rc-update add #{@new_resource.service_name} default")
|
48
|
-
end
|
49
|
-
|
50
|
-
def disable_service()
|
51
|
-
run_command(:command => "/sbin/rc-update del #{@new_resource.service_name} default")
|
52
|
-
end
|
53
|
-
end
|