diff options
-rw-r--r-- | lib/chef/provider/service/freebsd.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb index 08d58232e1..4cc8c5b8d9 100644 --- a/lib/chef/provider/service/freebsd.rb +++ b/lib/chef/provider/service/freebsd.rb @@ -58,6 +58,11 @@ class Chef requirements.assert(:start, :enable, :reload, :restart) do |a| a.assertion { init_command } a.failure_message Chef::Exceptions::Service, "#{new_resource}: unable to locate the rc.d script" + a.whyrun("Assuming rc.d script will be installed by a previous action.") do + # Assuming the missing rc.d script is for a user-installed rather than system + # service, fallback on the expected rc.d script path. + init_command = "/usr/local/etc/rc.d/#{new_resource.service_name}" + end end requirements.assert(:all_actions) do |a| @@ -131,6 +136,10 @@ class Chef # For example: to enable the service mysql-server with the init command /usr/local/etc/rc.d/mysql-server, you need # to set mysql_enable="YES" in /etc/rc.conf$ if init_command + if !::File.exists?(init_command) && whyrun_mode? + return new_resource.service_name + end + ::File.open(init_command) do |rcscript| rcscript.each_line do |line| if line =~ /^name="?(\w+)"?/ |