Sha256: 7c71de7b38393c39df0b83986243fce34549991125e4653d9f4bb0439909cfa5

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

#
# Copyright 2015, Nathan Williams <nath.e.will@gmail.com>
#
# 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.
#

class Chef
  module Sugar
    module Init
      extend self

      #
      # Determine if the current init system is systemd.
      #
      # @return [Boolean]
      #
      def systemd?(node)
        IO.read('/proc/1/comm').chomp == 'systemd'
      end

      #
      # Determine if the current init system is upstart.
      #
      # @return [Boolean]
      #
      def upstart?(node)
        File.executable?('/sbin/initctl')
      end

      #
      # Determine if the current init system is runit.
      #
      # @return [Boolean]
      #
      def runit?(node)
        File.executable?('/sbin/runit-init')
      end
    end

    module DSL
      # @see Chef::Sugar::Init#systemd?
      def systemd?; Chef::Sugar::Init.systemd?(node); end

      # @see Chef::Sugar::Init#upstart?
      def upstart?; Chef::Sugar::Init.upstart?(node); end

      # @see Chef::Sugar::Init#runit?
      def runit?; Chef::Sugar::Init.runit?(node); end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chef-sugar-3.4.0 lib/chef/sugar/init.rb
chef-sugar-3.3.0 lib/chef/sugar/init.rb
chef-sugar-3.2.0 lib/chef/sugar/init.rb