diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-08-29 15:47:58 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-09-08 11:10:05 -0700 |
commit | 342201b4e3ad90a0a5ddc62a1e4db76e95aea7e2 (patch) | |
tree | d4a2d6d86df86eab92532d67c732d03e14665bc7 /lib/chef/provider/service | |
parent | d6f6928fd1097709189cd78689e89032d4c9318d (diff) | |
download | chef-342201b4e3ad90a0a5ddc62a1e4db76e95aea7e2.tar.gz |
fix shell_out/run_command usage
- run_command is deprecated
- shell_out! should be used for internal APIs (enable/disable/status)
- shell_out_with_systems_locale! should be used for
start/stop/restart/reload cases (users will want their software
running in their systems locale not our forced en_US.UTF-8 locale)
Diffstat (limited to 'lib/chef/provider/service')
-rw-r--r-- | lib/chef/provider/service/debian.rb | 20 | ||||
-rw-r--r-- | lib/chef/provider/service/freebsd.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/service/gentoo.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/service/init.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/service/insserv.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/service/macosx.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/service/simple.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/service/solaris.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/service/systemd.rb | 18 | ||||
-rw-r--r-- | lib/chef/provider/service/upstart.rb | 10 |
10 files changed, 43 insertions, 43 deletions
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb index 06fe7fc480..1ebef90349 100644 --- a/lib/chef/provider/service/debian.rb +++ b/lib/chef/provider/service/debian.rb @@ -130,15 +130,15 @@ class Chef def enable_service if @new_resource.priority.is_a? Integer - run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove") - run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults #{@new_resource.priority} #{100 - @new_resource.priority}") + 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 #{@new_resource.priority} #{100 - @new_resource.priority}") elsif @new_resource.priority.is_a? Hash # we call the same command regardless of we're enabling or disabling # users passing a Hash are responsible for setting their own start priorities set_priority else # No priority, go with update-rc.d defaults - run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove") - run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} defaults") + 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 @@ -146,16 +146,16 @@ class Chef def disable_service if @new_resource.priority.is_a? Integer # Stop processes in reverse order of start using '100 - start_priority' - run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove") - run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop #{100 - @new_resource.priority} 2 3 4 5 .") + shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove") + shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop #{100 - @new_resource.priority} 2 3 4 5 .") elsif @new_resource.priority.is_a? Hash # we call the same command regardless of we're enabling or disabling # users passing a Hash are responsible for setting their own stop priorities set_priority else # no priority, using '100 - 20 (update-rc.d default)' to stop in reverse order of start - run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove") - run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop 80 2 3 4 5 .") + shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove") + shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} stop 80 2 3 4 5 .") end end @@ -166,8 +166,8 @@ class Chef priority = o[1] args += "#{action} #{priority} #{level} . " end - run_command(:command => "/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove") - run_command(:command => "/usr/sbin/update-rc.d #{@new_resource.service_name} #{args}") + shell_out!("/usr/sbin/update-rc.d -f #{@new_resource.service_name} remove") + shell_out!("/usr/sbin/update-rc.d #{@new_resource.service_name} #{args}") end end end diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb index 7b69957cc6..08d58232e1 100644 --- a/lib/chef/provider/service/freebsd.rb +++ b/lib/chef/provider/service/freebsd.rb @@ -78,7 +78,7 @@ class Chef if new_resource.start_command super else - shell_out!("#{init_command} faststart") + shell_out_with_systems_locale!("#{init_command} faststart") end end @@ -86,7 +86,7 @@ class Chef if new_resource.stop_command super else - shell_out!("#{init_command} faststop") + shell_out_with_systems_locale!("#{init_command} faststop") end end @@ -94,7 +94,7 @@ class Chef if new_resource.restart_command super elsif new_resource.supports[:restart] - shell_out!("#{init_command} fastrestart") + shell_out_with_systems_locale!("#{init_command} fastrestart") else stop_service sleep 1 diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb index 1559c7893f..a68abfebc9 100644 --- a/lib/chef/provider/service/gentoo.rb +++ b/lib/chef/provider/service/gentoo.rb @@ -58,10 +58,10 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init end def enable_service() - run_command(:command => "/sbin/rc-update add #{@new_resource.service_name} default") + shell_out!("/sbin/rc-update add #{@new_resource.service_name} default") end def disable_service() - run_command(:command => "/sbin/rc-update del #{@new_resource.service_name} default") + shell_out!("/sbin/rc-update del #{@new_resource.service_name} default") end end diff --git a/lib/chef/provider/service/init.rb b/lib/chef/provider/service/init.rb index 23d9dde80a..5d8bb5bb38 100644 --- a/lib/chef/provider/service/init.rb +++ b/lib/chef/provider/service/init.rb @@ -50,7 +50,7 @@ class Chef if @new_resource.start_command super else - shell_out!("#{default_init_command} start") + shell_out_with_systems_locale!("#{default_init_command} start") end end @@ -58,7 +58,7 @@ class Chef if @new_resource.stop_command super else - shell_out!("#{default_init_command} stop") + shell_out_with_systems_locale!("#{default_init_command} stop") end end @@ -66,7 +66,7 @@ class Chef if @new_resource.restart_command super elsif @new_resource.supports[:restart] - shell_out!("#{default_init_command} restart") + shell_out_with_systems_locale!("#{default_init_command} restart") else stop_service sleep 1 @@ -78,7 +78,7 @@ class Chef if @new_resource.reload_command super elsif @new_resource.supports[:reload] - shell_out!("#{default_init_command} reload") + shell_out_with_systems_locale!("#{default_init_command} reload") end end end diff --git a/lib/chef/provider/service/insserv.rb b/lib/chef/provider/service/insserv.rb index 35767ee7b9..f4c85dd9d3 100644 --- a/lib/chef/provider/service/insserv.rb +++ b/lib/chef/provider/service/insserv.rb @@ -37,12 +37,12 @@ class Chef end def enable_service() - run_command(:command => "/sbin/insserv -r -f #{@new_resource.service_name}") - run_command(:command => "/sbin/insserv -d -f #{@new_resource.service_name}") + shell_out!("/sbin/insserv -r -f #{@new_resource.service_name}") + shell_out!("/sbin/insserv -d -f #{@new_resource.service_name}") end def disable_service() - run_command(:command => "/sbin/insserv -r -f #{@new_resource.service_name}") + shell_out!("/sbin/insserv -r -f #{@new_resource.service_name}") end end end diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index 36930ee4ac..cf5e554559 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -83,7 +83,7 @@ class Chef if @new_resource.start_command super else - shell_out!("launchctl load -w '#{@plist}'", :user => @owner_uid, :group => @owner_gid) + shell_out_with_systems_locale!("launchctl load -w '#{@plist}'", :user => @owner_uid, :group => @owner_gid) end end end @@ -95,7 +95,7 @@ class Chef if @new_resource.stop_command super else - shell_out!("launchctl unload '#{@plist}'", :user => @owner_uid, :group => @owner_gid) + shell_out_with_systems_locale!("launchctl unload '#{@plist}'", :user => @owner_uid, :group => @owner_gid) end end end diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb index 0eb983a0bf..bd51d15f84 100644 --- a/lib/chef/provider/service/simple.rb +++ b/lib/chef/provider/service/simple.rb @@ -85,16 +85,16 @@ class Chef end def start_service - shell_out!(@new_resource.start_command) + shell_out_with_systems_locale!(@new_resource.start_command) end def stop_service - shell_out!(@new_resource.stop_command) + shell_out_with_systems_locale!(@new_resource.stop_command) end def restart_service if @new_resource.restart_command - shell_out!(@new_resource.restart_command) + shell_out_with_systems_locale!(@new_resource.restart_command) else stop_service sleep 1 @@ -103,7 +103,7 @@ class Chef end def reload_service - shell_out!(@new_resource.reload_command) + shell_out_with_systems_locale!(@new_resource.reload_command) end protected diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb index 0c47a3462b..f0584dcf6d 100644 --- a/lib/chef/provider/service/solaris.rb +++ b/lib/chef/provider/service/solaris.rb @@ -56,7 +56,7 @@ class Chef alias_method :start_service, :enable_service def reload_service - shell_out!("#{default_init_command} refresh #{@new_resource.service_name}") + shell_out_with_systems_locale!("#{default_init_command} refresh #{@new_resource.service_name}") end def restart_service diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb index 6231603d03..31feee65d4 100644 --- a/lib/chef/provider/service/systemd.rb +++ b/lib/chef/provider/service/systemd.rb @@ -28,7 +28,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple if @new_resource.status_command Chef::Log.debug("#{@new_resource} you have specified a status command, running..") - unless shell_out_with_systems_locale(@new_resource.status_command).error? + unless shell_out(@new_resource.status_command).error? @current_resource.running(true) else @status_check_success = false @@ -61,7 +61,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple if @new_resource.start_command super else - shell_out_with_systems_locale("/bin/systemctl start #{@new_resource.service_name}") + shell_out_with_systems_locale!("/bin/systemctl start #{@new_resource.service_name}") end end end @@ -73,7 +73,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple if @new_resource.stop_command super else - shell_out_with_systems_locale("/bin/systemctl stop #{@new_resource.service_name}") + shell_out_with_systems_locale!("/bin/systemctl stop #{@new_resource.service_name}") end end end @@ -82,7 +82,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple if @new_resource.restart_command super else - shell_out_with_systems_locale("/bin/systemctl restart #{@new_resource.service_name}") + shell_out_with_systems_locale!("/bin/systemctl restart #{@new_resource.service_name}") end end @@ -91,7 +91,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple super else if @current_resource.running - shell_out_with_systems_locale("/bin/systemctl reload #{@new_resource.service_name}") + shell_out_with_systems_locale!("/bin/systemctl reload #{@new_resource.service_name}") else start_service end @@ -99,18 +99,18 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple end def enable_service - shell_out_with_systems_locale("/bin/systemctl enable #{@new_resource.service_name}") + shell_out!("/bin/systemctl enable #{@new_resource.service_name}") end def disable_service - shell_out_with_systems_locale("/bin/systemctl disable #{@new_resource.service_name}") + shell_out!("/bin/systemctl disable #{@new_resource.service_name}") end def is_active? - shell_out_with_systems_locale("/bin/systemctl is-active #{@new_resource.service_name} --quiet").exitstatus == 0 + shell_out("/bin/systemctl is-active #{@new_resource.service_name} --quiet").exitstatus == 0 end def is_enabled? - shell_out_with_systems_locale("/bin/systemctl is-enabled #{@new_resource.service_name} --quiet").exitstatus == 0 + shell_out("/bin/systemctl is-enabled #{@new_resource.service_name} --quiet").exitstatus == 0 end end diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb index c81a8a50dc..5c021e8cb7 100644 --- a/lib/chef/provider/service/upstart.rb +++ b/lib/chef/provider/service/upstart.rb @@ -97,7 +97,7 @@ class Chef Chef::Log.debug("#{@new_resource} you have specified a status command, running..") begin - if run_command_with_systems_locale(:command => @new_resource.status_command) == 0 + if shell_out!(@new_resource.status_command) == 0 @current_resource.running true end rescue Chef::Exceptions::Exec @@ -153,7 +153,7 @@ class Chef if @new_resource.start_command super else - run_command_with_systems_locale(:command => "/sbin/start #{@job}") + shell_out_with_systems_locale!("/sbin/start #{@job}") end end end @@ -167,7 +167,7 @@ class Chef if @new_resource.stop_command super else - run_command_with_systems_locale(:command => "/sbin/stop #{@job}") + shell_out_with_systems_locale!("/sbin/stop #{@job}") end end end @@ -179,7 +179,7 @@ class Chef # Older versions of upstart would fail on restart if the service was currently stopped, check for that. LP:430883 else if @current_resource.running - run_command_with_systems_locale(:command => "/sbin/restart #{@job}") + shell_out_with_systems_locale!("/sbin/restart #{@job}") else start_service end @@ -191,7 +191,7 @@ class Chef super else # upstart >= 0.6.3-4 supports reload (HUP) - run_command_with_systems_locale(:command => "/sbin/reload #{@job}") + shell_out_with_systems_locale!("/sbin/reload #{@job}") end end |