summaryrefslogtreecommitdiff
path: root/lib/chef/provider/service
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/provider/service')
-rw-r--r--lib/chef/provider/service/aix.rb2
-rw-r--r--lib/chef/provider/service/aixinit.rb10
-rw-r--r--lib/chef/provider/service/arch.rb6
-rw-r--r--lib/chef/provider/service/debian.rb17
-rw-r--r--lib/chef/provider/service/freebsd.rb2
-rw-r--r--lib/chef/provider/service/macosx.rb2
-rw-r--r--lib/chef/provider/service/openbsd.rb2
-rw-r--r--lib/chef/provider/service/redhat.rb2
-rw-r--r--lib/chef/provider/service/simple.rb3
-rw-r--r--lib/chef/provider/service/solaris.rb2
-rw-r--r--lib/chef/provider/service/upstart.rb4
-rw-r--r--lib/chef/provider/service/windows.rb5
12 files changed, 29 insertions, 28 deletions
diff --git a/lib/chef/provider/service/aix.rb b/lib/chef/provider/service/aix.rb
index 6f0eba7737..201f9ff5f9 100644
--- a/lib/chef/provider/service/aix.rb
+++ b/lib/chef/provider/service/aix.rb
@@ -90,6 +90,7 @@ class Chef
end
protected
+
def determine_current_status!
Chef::Log.debug "#{@new_resource} using lssrc to check the status"
begin
@@ -126,4 +127,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb
index c6483c3f59..6b451d649a 100644
--- a/lib/chef/provider/service/aixinit.rb
+++ b/lib/chef/provider/service/aixinit.rb
@@ -57,14 +57,14 @@ class Chef
end
def enable_service
- Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f)}
+ Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
if @new_resource.priority.is_a? Integer
create_symlink(2, "S", @new_resource.priority)
elsif @new_resource.priority.is_a? Hash
- @new_resource.priority.each do |level,o|
- create_symlink(level,(o[0] == :start ? "S" : "K"),o[1])
+ @new_resource.priority.each do |level, o|
+ create_symlink(level, (o[0] == :start ? "S" : "K"), o[1])
end
else
create_symlink(2, "S", "")
@@ -75,9 +75,9 @@ class Chef
Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
if @new_resource.priority.is_a? Integer
- create_symlink(2, "K",100 - @new_resource.priority)
+ create_symlink(2, "K", 100 - @new_resource.priority)
elsif @new_resource.priority.is_a? Hash
- @new_resource.priority.each do |level,o|
+ @new_resource.priority.each do |level, o|
create_symlink(level, "K", 100 - o[1]) if o[0] == :stop
end
else
diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb
index 66504390e8..9c66fb4098 100644
--- a/lib/chef/provider/service/arch.rb
+++ b/lib/chef/provider/service/arch.rb
@@ -32,8 +32,8 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
end
def load_current_resource
- raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf")
- raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
+ raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf")
+ raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
super
@current_resource.enabled(daemons.include?(@current_resource.service_name))
@@ -50,7 +50,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
def daemons
entries = []
if ::File.read("/etc/rc.conf").match(/DAEMONS=\((.*)\)/m)
- entries += $1.gsub(/\\?[\r\n]/, " ").gsub(/# *[^ ]+/," ").split(" ") if $1.length > 0
+ entries += $1.gsub(/\\?[\r\n]/, " ").gsub(/# *[^ ]+/, " ").split(" ") if $1.length > 0
end
yield(entries) if block_given?
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index e67f5ca95d..6550c85b2a 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -55,18 +55,18 @@ class Chef
requirements.assert(:all_actions) do |a|
a.assertion { @priority_success }
- a.failure_message Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{current_resource.service_name} failed - #{@rcd_status.inspect}"
+ a.failure_message Chef::Exceptions::Service, "/usr/sbin/update-rc.d -n -f #{current_resource.service_name} failed - #{@rcd_status.inspect}"
# This can happen if the service is not yet installed,so we'll fake it.
a.whyrun ["Unable to determine priority of service, assuming service would have been correctly installed earlier in the run.",
"Assigning temporary priorities to continue.",
"If this service is not properly installed prior to this point, this will fail."] do
- temp_priorities = {"6"=>[:stop, "20"],
- "0"=>[:stop, "20"],
- "1"=>[:stop, "20"],
- "2"=>[:start, "20"],
- "3"=>[:start, "20"],
- "4"=>[:start, "20"],
- "5"=>[:start, "20"]}
+ temp_priorities = { "6" => [:stop, "20"],
+ "0" => [:stop, "20"],
+ "1" => [:stop, "20"],
+ "2" => [:start, "20"],
+ "3" => [:start, "20"],
+ "4" => [:start, "20"],
+ "5" => [:start, "20"] }
current_resource.priority(temp_priorities)
end
end
@@ -148,7 +148,6 @@ class Chef
shell_out!("/usr/sbin/update-rc.d -f #{new_resource.service_name} remove")
shell_out!("/usr/sbin/update-rc.d #{new_resource.service_name} defaults")
end
-
end
def disable_service
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb
index fc0743d5e4..7e475fc878 100644
--- a/lib/chef/provider/service/freebsd.rb
+++ b/lib/chef/provider/service/freebsd.rb
@@ -51,7 +51,7 @@ class Chef
Chef::Log.debug("#{current_resource} found at #{init_command}")
@status_load_success = true
- determine_current_status! # see Chef::Provider::Service::Simple
+ determine_current_status! # see Chef::Provider::Service::Simple
determine_enabled_status!
current_resource
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 4206f29aef..63485903c3 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -83,7 +83,7 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion {::File.exists?(@plist.to_s) }
+ a.assertion { ::File.exists?(@plist.to_s) }
a.failure_message Chef::Exceptions::Service,
"Could not find plist for #{@new_resource}"
end
diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb
index 4fc10cff5c..c31df25e68 100644
--- a/lib/chef/provider/service/openbsd.rb
+++ b/lib/chef/provider/service/openbsd.rb
@@ -117,7 +117,7 @@ class Chef
old_list = rc_conf_local.match(/^pkg_scripts="(.*)"/)
old_list = old_list ? old_list[1].split(" ") : []
new_list = old_list - [new_resource.service_name]
- update_rcl rc_conf_local.sub(/^pkg_scripts="(.*)"/, pkg_scripts="#{new_list.join(' ')}")
+ update_rcl rc_conf_local.sub(/^pkg_scripts="(.*)"/, pkg_scripts = "#{new_list.join(' ')}")
end
end
end
diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb
index 58c8d4d30a..a76622ee8f 100644
--- a/lib/chef/provider/service/redhat.rb
+++ b/lib/chef/provider/service/redhat.rb
@@ -75,7 +75,7 @@ class Chef
super
if ::File.exists?("/sbin/chkconfig")
- chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0,1])
+ chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0, 1])
unless run_levels.nil? or run_levels.empty?
all_levels_match = true
chkconfig.stdout.split(/\s+/)[1..-1].each do |level|
diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb
index b954a118dd..d76779a74b 100644
--- a/lib/chef/provider/service/simple.rb
+++ b/lib/chef/provider/service/simple.rb
@@ -66,7 +66,7 @@ class Chef
end
requirements.assert(:restart) do |a|
- a.assertion { @new_resource.restart_command || ( @new_resource.start_command && @new_resource.stop_command ) }
+ a.assertion { @new_resource.restart_command || ( @new_resource.start_command && @new_resource.stop_command ) }
a.failure_message Chef::Exceptions::Service, "#{self} requires a restart_command or both start_command and stop_command be set in order to perform a restart"
end
@@ -109,6 +109,7 @@ class Chef
end
protected
+
def determine_current_status!
if @new_resource.status_command
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb
index b302441a60..0787392094 100644
--- a/lib/chef/provider/service/solaris.rb
+++ b/lib/chef/provider/service/solaris.rb
@@ -28,7 +28,7 @@ class Chef
provides :service, os: "solaris2"
- def initialize(new_resource, run_context=nil)
+ def initialize(new_resource, run_context = nil)
super
@init_command = "/usr/sbin/svcadm"
@status_command = "/bin/svcs"
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 2aacdf3915..edd41dba7e 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -89,7 +89,7 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion { @config_file_found }
+ a.assertion { @config_file_found }
# no failure here, just document the assumptions made.
a.whyrun "Could not find #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}. Assuming service is disabled."
end
@@ -130,7 +130,7 @@ class Chef
# Get enabled/disabled state by reading job configuration file
if ::File.exists?("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
Chef::Log.debug("#{@new_resource} found #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
- ::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}","r") do |file|
+ ::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}", "r") do |file|
while line = file.gets
case line
when /^start on/
diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb
index 8c7c76df3f..2705aa5c02 100644
--- a/lib/chef/provider/service/windows.rb
+++ b/lib/chef/provider/service/windows.rb
@@ -45,7 +45,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
START_PENDING = "start pending"
STOP_PENDING = "stop pending"
- TIMEOUT = 60
+ TIMEOUT = 60
SERVICE_RIGHT = "SeServiceLogonRight"
@@ -75,7 +75,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
service_name: @new_resource.service_name,
service_start_name: @new_resource.run_as_user,
password: @new_resource.run_as_password,
- }.reject { |k,v| v.nil? || v.length == 0 }
+ }.reject { |k, v| v.nil? || v.length == 0 }
Win32::Service.configure(new_config)
Chef::Log.info "#{@new_resource} configured with #{new_config.inspect}"
@@ -238,6 +238,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
end
private
+
def grant_service_logon(username)
begin
Chef::ReservedNames::Win32::Security.add_account_right(canonicalize_username(username), SERVICE_RIGHT)