diff options
Diffstat (limited to 'lib/chef/provider/service')
-rw-r--r-- | lib/chef/provider/service/aix.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/service/aixinit.rb | 16 | ||||
-rw-r--r-- | lib/chef/provider/service/arch.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/service/debian.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/service/freebsd.rb | 10 | ||||
-rw-r--r-- | lib/chef/provider/service/gentoo.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/service/init.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/service/insserv.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/service/invokercd.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/service/macosx.rb | 28 | ||||
-rw-r--r-- | lib/chef/provider/service/openbsd.rb | 24 | ||||
-rw-r--r-- | lib/chef/provider/service/redhat.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/service/simple.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/service/solaris.rb | 12 | ||||
-rw-r--r-- | lib/chef/provider/service/systemd.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/service/upstart.rb | 12 | ||||
-rw-r--r-- | lib/chef/provider/service/windows.rb | 32 |
17 files changed, 92 insertions, 92 deletions
diff --git a/lib/chef/provider/service/aix.rb b/lib/chef/provider/service/aix.rb index 0c95ce2c8e..1968f8f3de 100644 --- a/lib/chef/provider/service/aix.rb +++ b/lib/chef/provider/service/aix.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/provider/service' +require "chef/provider/service" class Chef class Provider @@ -98,7 +98,7 @@ class Chef @current_resource.running false else service = shell_out!("lssrc -s #{@new_resource.service_name}").stdout - if service.split(' ').last == 'active' + if service.split(" ").last == "active" @current_resource.running true else @current_resource.running false diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb index 19beac79f0..66d85984fa 100644 --- a/lib/chef/provider/service/aixinit.rb +++ b/lib/chef/provider/service/aixinit.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/provider/service/init' +require "chef/provider/service/init" class Chef class Provider @@ -60,14 +60,14 @@ 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, 'S', @new_resource.priority) + 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]) + create_symlink(level,(o[0] == :start ? "S" : "K"),o[1]) end else - create_symlink(2, 'S', '') + create_symlink(2, "S", "") end end @@ -75,13 +75,13 @@ 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| - create_symlink(level, 'K', 100 - o[1]) if o[0] == :stop + create_symlink(level, "K", 100 - o[1]) if o[0] == :stop end else - create_symlink(2, 'K', '') + create_symlink(2, "K", "") end end @@ -98,7 +98,7 @@ class Chef files.each do |file| if (RC_D_SCRIPT_NAME =~ file) - priority[2] = [($1 == "S" ? :start : :stop), ($2.empty? ? '' : $2.to_i)] + priority[2] = [($1 == "S" ? :start : :stop), ($2.empty? ? "" : $2.to_i)] if $1 == "S" is_enabled = true end diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb index e7fbcc820c..3e7b9fcaca 100644 --- a/lib/chef/provider/service/arch.rb +++ b/lib/chef/provider/service/arch.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/provider/service/init' +require "chef/provider/service/init" class Chef::Provider::Service::Arch < Chef::Provider::Service::Init @@ -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 7d23e4ac77..9d80f5f924 100644 --- a/lib/chef/provider/service/debian.rb +++ b/lib/chef/provider/service/debian.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'chef/provider/service/init' +require "chef/provider/service/init" class Chef class Provider class Service class Debian < Chef::Provider::Service::Init - provides :service, platform_family: 'debian' do |node| + provides :service, platform_family: "debian" do |node| Chef::Platform::ServiceHelpers.service_resource_providers.include?(:debian) end diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb index 78ca0be235..4aa9eb09f6 100644 --- a/lib/chef/provider/service/freebsd.rb +++ b/lib/chef/provider/service/freebsd.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/resource/service' -require 'chef/provider/service/init' -require 'chef/mixin/command' +require "chef/resource/service" +require "chef/provider/service/init" +require "chef/mixin/command" class Chef class Provider @@ -119,11 +119,11 @@ class Chef private def read_rc_conf - ::File.open("/etc/rc.conf", 'r') { |file| file.readlines } + ::File.open("/etc/rc.conf", "r") { |file| file.readlines } end def write_rc_conf(lines) - ::File.open("/etc/rc.conf", 'w') do |file| + ::File.open("/etc/rc.conf", "w") do |file| lines.each { |line| file.puts(line) } end end diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb index 903c55af7a..28fd43a709 100644 --- a/lib/chef/provider/service/gentoo.rb +++ b/lib/chef/provider/service/gentoo.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require 'chef/provider/service/init' -require 'chef/mixin/command' -require 'chef/util/path_helper' +require "chef/provider/service/init" +require "chef/mixin/command" +require "chef/util/path_helper" class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init diff --git a/lib/chef/provider/service/init.rb b/lib/chef/provider/service/init.rb index 8fe5b0281f..90c0ec2b34 100644 --- a/lib/chef/provider/service/init.rb +++ b/lib/chef/provider/service/init.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/provider/service/simple' -require 'chef/mixin/command' -require 'chef/platform/service_helpers' +require "chef/provider/service/simple" +require "chef/mixin/command" +require "chef/platform/service_helpers" class Chef class Provider diff --git a/lib/chef/provider/service/insserv.rb b/lib/chef/provider/service/insserv.rb index dd01f9ab87..87527599b0 100644 --- a/lib/chef/provider/service/insserv.rb +++ b/lib/chef/provider/service/insserv.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/provider/service/init' -require 'chef/util/path_helper' +require "chef/provider/service/init" +require "chef/util/path_helper" class Chef class Provider diff --git a/lib/chef/provider/service/invokercd.rb b/lib/chef/provider/service/invokercd.rb index 2b045e0e60..a48e2ac815 100644 --- a/lib/chef/provider/service/invokercd.rb +++ b/lib/chef/provider/service/invokercd.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'chef/provider/service/init' +require "chef/provider/service/init" class Chef class Provider class Service class Invokercd < Chef::Provider::Service::Init - provides :service, platform_family: 'debian', override: true do |node| + provides :service, platform_family: "debian", override: true do |node| Chef::Platform::ServiceHelpers.service_resource_providers.include?(:invokercd) end diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index 47c74f9425..b939f78b03 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'etc' -require 'rexml/document' -require 'chef/resource/service' -require 'chef/resource/macosx_service' -require 'chef/provider/service/simple' -require 'chef/util/path_helper' +require "etc" +require "rexml/document" +require "chef/resource/service" +require "chef/resource/macosx_service" +require "chef/provider/service/simple" +require "chef/util/path_helper" class Chef class Provider @@ -36,14 +36,14 @@ class Chef /Library/LaunchDaemons /System/Library/LaunchAgents /System/Library/LaunchDaemons } - Chef::Util::PathHelper.home('Library', 'LaunchAgents') { |p| locations << p } + Chef::Util::PathHelper.home("Library", "LaunchAgents") { |p| locations << p } locations end PLIST_DIRS = gather_plist_dirs def this_version_or_newer?(this_version) - Gem::Version.new(node['platform_version']) >= Gem::Version.new(this_version) + Gem::Version.new(node["platform_version"]) >= Gem::Version.new(this_version) end def load_current_resource @@ -53,17 +53,17 @@ class Chef @plist = @new_resource.plist ? @new_resource.plist : find_service_plist @service_label = find_service_label # LauchAgents should be loaded as the console user. - @console_user = @plist ? @plist.include?('LaunchAgents') : false + @console_user = @plist ? @plist.include?("LaunchAgents") : false @session_type = @new_resource.session_type if @console_user @console_user = Etc.getlogin Chef::Log.debug("#{new_resource} console_user: '#{@console_user}'") cmd = "su " - param = this_version_or_newer?('10.10') ? '' : '-l ' + param = this_version_or_newer?("10.10") ? "" : "-l " @base_user_cmd = cmd + param + "#{@console_user} -c" # Default LauchAgent session should be Aqua - @session_type = 'Aqua' if @session_type.nil? + @session_type = "Aqua" if @session_type.nil? end Chef::Log.debug("#{new_resource} Plist: '#{@plist}' service_label: '#{@service_label}'") @@ -161,13 +161,13 @@ class Chef end def load_service - session = @session_type ? "-S #{@session_type} " : '' - cmd = 'launchctl load -w ' + session + @plist + session = @session_type ? "-S #{@session_type} " : "" + cmd = "launchctl load -w " + session + @plist shell_out_as_user(cmd) end def unload_service - cmd = 'launchctl unload -w ' + @plist + cmd = "launchctl unload -w " + @plist shell_out_as_user(cmd) end diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb index 36c9e8141e..10d7b21953 100644 --- a/lib/chef/provider/service/openbsd.rb +++ b/lib/chef/provider/service/openbsd.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'chef/mixin/command' -require 'chef/mixin/shell_out' -require 'chef/provider/service/init' -require 'chef/resource/service' +require "chef/mixin/command" +require "chef/mixin/shell_out" +require "chef/provider/service/init" +require "chef/resource/service" class Chef class Provider @@ -32,13 +32,13 @@ class Chef attr_reader :init_command, :rc_conf, :rc_conf_local, :enabled_state_found - RC_CONF_PATH = '/etc/rc.conf' - RC_CONF_LOCAL_PATH = '/etc/rc.conf.local' + RC_CONF_PATH = "/etc/rc.conf" + RC_CONF_LOCAL_PATH = "/etc/rc.conf.local" def initialize(new_resource, run_context) super - @rc_conf = ::File.read(RC_CONF_PATH) rescue '' - @rc_conf_local = ::File.read(RC_CONF_LOCAL_PATH) rescue '' + @rc_conf = ::File.read(RC_CONF_PATH) rescue "" + @rc_conf_local = ::File.read(RC_CONF_LOCAL_PATH) rescue "" @init_command = ::File.exist?(rcd_script_path) ? rcd_script_path : nil new_resource.status_command("#{default_init_command} check") end @@ -82,7 +82,7 @@ class Chef if !is_enabled? if is_builtin? if is_enabled_by_default? - update_rcl rc_conf_local.sub(/^#{Regexp.escape(builtin_service_enable_variable_name)}=.*/, '') + update_rcl rc_conf_local.sub(/^#{Regexp.escape(builtin_service_enable_variable_name)}=.*/, "") else # add line with blank string, which means enable update_rcl rc_conf_local + "\n" + "#{builtin_service_enable_variable_name}=\"\"\n" @@ -90,7 +90,7 @@ class Chef else # add to pkg_scripts, most recent addition goes last old_services_list = rc_conf_local.match(/^pkg_scripts="(.*)"/) - old_services_list = old_services_list ? old_services_list[1].split(' ') : [] + old_services_list = old_services_list ? old_services_list[1].split(" ") : [] new_services_list = old_services_list + [new_resource.service_name] if rc_conf_local.match(/^pkg_scripts="(.*)"/) new_rcl = rc_conf_local.sub(/^pkg_scripts="(.*)"/, "pkg_scripts=\"#{new_services_list.join(' ')}\"") @@ -110,12 +110,12 @@ class Chef update_rcl rc_conf_local + "\n" + "#{builtin_service_enable_variable_name}=\"NO\"\n" else # remove line to disable - update_rcl rc_conf_local.sub(/^#{Regexp.escape(builtin_service_enable_variable_name)}=.*/, '') + update_rcl rc_conf_local.sub(/^#{Regexp.escape(builtin_service_enable_variable_name)}=.*/, "") end else # remove from pkg_scripts old_list = rc_conf_local.match(/^pkg_scripts="(.*)"/) - old_list = old_list ? old_list[1].split(' ') : [] + 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(' ')}") end diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb index 3ad11a7672..f93cd36348 100644 --- a/lib/chef/provider/service/redhat.rb +++ b/lib/chef/provider/service/redhat.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/provider/service/init' +require "chef/provider/service/init" class Chef class Provider @@ -79,8 +79,8 @@ class Chef unless run_levels.nil? or run_levels.empty? all_levels_match = true chkconfig.stdout.split(/\s+/)[1..-1].each do |level| - index = level.split(':').first - status = level.split(':').last + index = level.split(":").first + status = level.split(":").last if level =~ CHKCONFIG_ON @current_run_levels << index.to_i all_levels_match = false unless run_levels.include?(index.to_i) diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb index bb3d819b3d..a096c9dfc0 100644 --- a/lib/chef/provider/service/simple.rb +++ b/lib/chef/provider/service/simple.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/provider/service' -require 'chef/resource/service' -require 'chef/mixin/command' +require "chef/provider/service" +require "chef/resource/service" +require "chef/mixin/command" class Chef class Provider diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb index 7040503c6b..c43a25258c 100644 --- a/lib/chef/provider/service/solaris.rb +++ b/lib/chef/provider/service/solaris.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/provider/service' -require 'chef/resource/service' -require 'chef/mixin/command' +require "chef/provider/service" +require "chef/resource/service" +require "chef/mixin/command" class Chef class Provider @@ -96,11 +96,11 @@ class Chef # check service state @maintenance = false - case status['state'] - when 'online' + case status["state"] + when "online" @current_resource.enabled(true) @current_resource.running(true) - when 'maintenance' + when "maintenance" @maintenance = true end diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb index d41f6248c2..bf4b324dce 100644 --- a/lib/chef/provider/service/systemd.rb +++ b/lib/chef/provider/service/systemd.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/resource/service' -require 'chef/provider/service/simple' -require 'chef/mixin/which' +require "chef/resource/service" +require "chef/provider/service/simple" +require "chef/mixin/which" class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb index 8d9adaa3b3..c0f7e020f6 100644 --- a/lib/chef/provider/service/upstart.rb +++ b/lib/chef/provider/service/upstart.rb @@ -16,17 +16,17 @@ # limitations under the License. # -require 'chef/resource/service' -require 'chef/provider/service/simple' -require 'chef/mixin/command' -require 'chef/util/file_edit' +require "chef/resource/service" +require "chef/provider/service/simple" +require "chef/mixin/command" +require "chef/util/file_edit" class Chef class Provider class Service class Upstart < Chef::Provider::Service::Simple - provides :service, platform_family: 'debian', override: true do |node| + provides :service, platform_family: "debian", override: true do |node| Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart) 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 fcebeeb6c6..0ae3c5b09f 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -18,10 +18,10 @@ # limitations under the License. # -require 'chef/provider/service/simple' +require "chef/provider/service/simple" if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - require 'chef/win32/error' - require 'win32/service' + require "chef/win32/error" + require "win32/service" end class Chef::Provider::Service::Windows < Chef::Provider::Service @@ -32,22 +32,22 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service include Chef::ReservedNames::Win32::API::Error rescue LoadError #Win32::Service.get_start_type - AUTO_START = 'auto start' - MANUAL = 'demand start' - DISABLED = 'disabled' + AUTO_START = "auto start" + MANUAL = "demand start" + DISABLED = "disabled" #Win32::Service.get_current_state - RUNNING = 'running' - STOPPED = 'stopped' - CONTINUE_PENDING = 'continue pending' - PAUSE_PENDING = 'pause pending' - PAUSED = 'paused' - START_PENDING = 'start pending' - STOP_PENDING = 'stop pending' + RUNNING = "running" + STOPPED = "stopped" + CONTINUE_PENDING = "continue pending" + PAUSE_PENDING = "pause pending" + PAUSED = "paused" + START_PENDING = "start pending" + STOP_PENDING = "stop pending" TIMEOUT = 60 - SERVICE_RIGHT = 'SeServiceLogonRight' + SERVICE_RIGHT = "SeServiceLogonRight" def whyrun_supported? false @@ -252,11 +252,11 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service # remove characters that make for broken or wonky filenames. def clean_username_for_path(username) - username.gsub(/[\/\\. ]+/, '_') + username.gsub(/[\/\\. ]+/, "_") end def canonicalize_username(username) - username.sub(/^\.?\\+/, '') + username.sub(/^\.?\\+/, "") end def current_state |