Sha256: 3c175b768f6b1721444f28f20fb621fb3b2003b342889d9820a13cc36193c053

Contents?: true

Size: 861 Bytes

Versions: 6

Compression:

Stored size: 861 Bytes

Contents

module LinuxAdmin
  class Service
    extend Common
    include Common
    include Logging

    def self.service_type(reload = false)
      return @service_type if @service_type && !reload
      @service_type = service_type_uncached
    end

    class << self
      private
      alias_method :orig_new, :new
    end

    def self.new(*args)
      if self == LinuxAdmin::Service
        service_type.new(*args)
      else
        orig_new(*args)
      end
    end

    attr_accessor :name

    def initialize(name)
      @name = name
    end

    alias_method :id, :name
    alias_method :id=, :name=

    private

    def self.service_type_uncached
      cmd?(:systemctl) ? SystemdService : SysVInitService
    end
    private_class_method :service_type_uncached
  end
end

Dir.glob(File.join(File.dirname(__FILE__), "service", "*.rb")).each { |f| require f }

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
linux_admin-0.14.0 lib/linux_admin/service.rb
linux_admin-0.13.0 lib/linux_admin/service.rb
linux_admin-0.12.1 lib/linux_admin/service.rb
linux_admin-0.12.0 lib/linux_admin/service.rb
linux_admin-0.11.1 lib/linux_admin/service.rb
linux_admin-0.11.0 lib/linux_admin/service.rb