Sha256: fc7d3573f30a2376f7a8d6a5f7d7dde416cb3a263bc31a01c13f60a5062e2a3a

Contents?: true

Size: 1.33 KB

Versions: 9

Compression:

Stored size: 1.33 KB

Contents

# Manage FreeBSD services.
Puppet::Type.type(:service).provide :bsd, :parent => :init do
  desc <<-EOT
    FreeBSD's (and probably NetBSD's?) form of `init`-style service management.

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

  EOT

  confine :operatingsystem => [:freebsd, :netbsd, :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, @model[: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, @model[: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, @model[:name])
    open(rcfile, 'w') { |f| f << "%s_enable=\"YES\"\n" % @model[: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

9 entries across 9 versions & 1 rubygems

Version Path
puppet-4.1.0 lib/puppet/provider/service/bsd.rb
puppet-4.1.0-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.1.0-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.0.0 lib/puppet/provider/service/bsd.rb
puppet-4.0.0-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.0.0-x64-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.0.0.rc1 lib/puppet/provider/service/bsd.rb
puppet-4.0.0.rc1-x86-mingw32 lib/puppet/provider/service/bsd.rb
puppet-4.0.0.rc1-x64-mingw32 lib/puppet/provider/service/bsd.rb