lib/facter/initsystem.rb
def initsystem_lookup
  # Whilst we include logic for automatically selecting the initsystem based
  # on what is present on the system, it doesn't always work 100% since there
  # are some distributions with multiple init systems present, and it's not
  # always the case of the most modern init system being the right one to use.
  #
  # Hence, here we do a lookup against our curated list for a specific
  # configured match:
  initsystem = initsystem_curated

  if initsystem.empty?
    # We don't have a specific match for this system, so let's check for
    # various known platforms.

    # TODO: this could be a lot more sophisticated, patches welcome.

    if File.exist?('/bin/systemctl')
      return 'systemd'
    elsif File.exist?('/sbin/upstart-local-bridge')
      return 'upstart'
    else
      # sysvinit is the safest default to fall back to, even many distributions
      # with other init systems maintain some compatibility.
      return 'sysvinit'
    end

  else
    return initsystem
  end
end
# vim: ai ts=2 sts=2 et sw=2 ft=ruby
# Fact that returns the primary init system for a particular system using
# either a curated list of known answers, or falling back to automatic
# detection.
ai ts=2 sts=2 et sw=2 ft=ruby
Fact that returns the primary init system for a particular system using
either a curated list of known answers, or falling back to automatic
detection.
ai ts = 2 sts = 2 et sw = 2 ft = ruby Fact that returns the primary init system for a particular system using either a curated list of known answers or falling back to automatic detection .
def initsystem_lookup
   Hence, here we do a lookup against our curated list for a specific
   configured match:
  initsystem = initsystem_curated
  if initsystem.empty?
     We don't have a specific match for this system, so let's check for
     various known platforms.
     TODO: this could be a lot more sophisticated, patches welcome.
    if File.exist?('/bin/systemctl')
      return 'systemd'
    elsif File.exist?('/sbin/upstart-local-bridge')
      return 'upstart'
    else
       sysvinit is the safest default to fall back to, even many distributions
       with other init systems maintain some compatibility.
      return 'sysvinit'
    end
  else
    return initsystem
  end
end
def initsystem_lookup initsystem = initsystem_curated if initsystem . empty? if File . exist? ( '/bin/systemctl' ) return 'systemd' elsif File . exist? ( '/sbin/upstart-local-bridge' ) return 'upstart' else return 'sysvinit' end else return initsystem end end
vim: ai ts=2 sts=2 et sw=2 ft=ruby
Fact that returns the primary init system for a particular system using
either a curated list of known answers, or falling back to automatic
detection.
vim : ai ts = 2 sts = 2 et sw = 2 ft = ruby Fact that returns the primary init system for a particular system using either a curated list of known answers or falling back to automatic detection .
# Whilst we include logic for automatically selecting the initsystem based # on what is present on the system, it doesn't always work 100% since there # are some distributions with multiple init systems present, and it's not # always the case of the most modern init system being the right one to use. # # Hence, here we do a lookup against our curated list for a specific # configured match: # We don't have a specific match for this system, so let's check for # various known platforms. # TODO: this could be a lot more sophisticated, patches welcome. # sysvinit is the safest default to fall back to, even many distributions # with other init systems maintain some compatibility.