<commit_before>#
# Cookbook Name:: runit
# Recipe:: default
#
# Copyright 2008-2010, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

case node["platform_family"]
when "debian"
  case node["platform"]
  when "debian", "raspbian", "devuan"
    if File.exist?("/sbin/init")
       if File.symlink?("/sbin/init")
         if File.basename(File.readlink("/sbin/init")) == "systemd"
           include_recipe "runit::systemd"
         else
           include_recipe "runit::upstart"
         end
       else
         include_recipe "runit::sysvinit"
       end
    else
      if node["platform_version"] =~ /^8/
        include_recipe "runit::systemd"
      else
        include_recipe "runit::sysvinit"
      end
    end
  else
    include_recipe "runit::upstart"
  end
when "rhel"
  case node["platform"]
  when "amazon", "xenserver"
    # TODO: platform_version check for old distro without upstart
    include_recipe "runit::upstart"
  else
    if node['platform_version'] =~ /^5/
      include_recipe "runit::sysvinit"
    elsif node['platform_version'] =~ /^6/
      include_recipe "runit::upstart"
    elsif node['platform_version'] =~ /^7/
      include_recipe "runit::systemd"
    end
  end
when "fedora"
  include_recipe "runit::systemd"
else
  include_recipe "runit::sysvinit"
end<commit_msg>Try detecting init in use instead of guessing based on OS.<commit_after>#
# Cookbook Name:: runit
# Recipe:: default
#
# Copyright 2008-2010, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

if system('/sbin/init --version | grep upstart')
  Chef::Log.warn "Selected upstart because /sbin/init --version is showing upstart."
  include_recipe "runit::upstart"
elsif system('systemctl | grep "\-\.mount"')
  Chef::Log.warn "Selected systemd because systemctl shows it is mounted."
  include_recipe "runit::systemd"
else
  Chef::Log.warn "Selected sysvinit because it looks like it is not upstart or systemd."
  include_recipe "runit::sysvinit"
end
{'fraction_non_alphanumeric': 0.10366879838438237, 'fraction_numerical': 0.009424436216762033, 'mean_word_length': 3.658307210031348, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5993056', 'n_tokens_mistral': 918, 'n_tokens_neox': 895, 'n_words': 318}