Sha256: 823485e45036def4e8e489167041701df0c601be6c258df566b6d6827d9a08a6

Contents?: true

Size: 1.36 KB

Versions: 611

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 tries 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

611 entries across 611 versions & 3 rubygems

Version Path
puppet-7.34.0 lib/puppet/provider/service/bsd.rb
puppet-7.34.0-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.34.0-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.34.0-universal-darwin lib/puppet/provider/service/bsd.rb
puppet-7.33.0 lib/puppet/provider/service/bsd.rb
puppet-7.33.0-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.33.0-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.33.0-universal-darwin lib/puppet/provider/service/bsd.rb
puppet-7.32.1 lib/puppet/provider/service/bsd.rb
puppet-7.32.1-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.32.1-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.32.1-universal-darwin lib/puppet/provider/service/bsd.rb
puppet-7.31.0 lib/puppet/provider/service/bsd.rb
puppet-7.31.0-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.31.0-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.31.0-universal-darwin lib/puppet/provider/service/bsd.rb
puppet-7.30.0 lib/puppet/provider/service/bsd.rb
puppet-7.30.0-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.30.0-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-7.30.0-universal-darwin lib/puppet/provider/service/bsd.rb