Sha256: c84c78c292835ab4f5f39a5a5fa3b249f57a7e1d3aa5764e9373b77ab252490a

Contents?: true

Size: 1.36 KB

Versions: 47

Compression:

Stored size: 1.36 KB

Contents

Puppet::Type.type(:service).provide :bsd, :parent => :init do
  desc <<-EOT
    Generic BSD form of `init`-style service management with `rc.d`.

    Uses `rc.conf.d` for service enabling and disabling.
  EOT

  confine :operatingsystem => [:freebsd, :dragonfly]

  def rcconf_dir
    '/etc/rc.conf.d'
  end

  def self.defpath
    superclass.defpath
  end

  # remove service file from rc.conf.d to disable it
  def disable
    rcfile = File.join(rcconf_dir, @resource[:name])
    File.delete(rcfile) if Puppet::FileSystem.exist?(rcfile)
  end

  # if the service file exists in rc.conf.d then it's already enabled
  def enabled?
    rcfile = File.join(rcconf_dir, @resource[:name])
    return :true if Puppet::FileSystem.exist?(rcfile)

    :false
  end

  # enable service by creating a service file under rc.conf.d with the
  # proper contents
  def enable
    Dir.mkdir(rcconf_dir) if not Puppet::FileSystem.exist?(rcconf_dir)
    rcfile = File.join(rcconf_dir, @resource[:name])
    File.open(rcfile, File::WRONLY | File::APPEND | File::CREAT, 0644) { |f|
      f << "%s_enable=\"YES\"\n" % @resource[:name]
    }
  end

  # Override stop/start commands to use one<cmd>'s and the avoid race condition
  # where provider trys to stop/start the service before it is enabled
  def startcmd
    [self.initscript, :onestart]
  end

  def stopcmd
    [self.initscript, :onestop]
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
puppet-retrospec-1.5.0 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.4.1 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.4.0 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.3.2 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.3.1 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.3.0 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.2.1 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.2.0 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.1.0 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-4.5.3 lib/puppet/provider/service/bsd.rb
puppet-4.5.3-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.5.3-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.5.3-universal-darwin lib/puppet/provider/service/bsd.rb
puppet-retrospec-1.0.0 vendor/gems/puppet-4.5.2/lib/puppet/provider/service/bsd.rb
puppet-4.5.2 lib/puppet/provider/service/bsd.rb
puppet-4.5.2-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.5.2-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.5.2-universal-darwin lib/puppet/provider/service/bsd.rb
puppet-4.5.1 lib/puppet/provider/service/bsd.rb
puppet-4.5.1-x86-mingw32 lib/puppet/provider/service/bsd.rb