Fixed enabling services on OpenBSD 4.9.
This commit is contained in:
parent
8dcdcf5466
commit
3d66d00958
1 changed files with 12 additions and 6 deletions
|
@ -13,6 +13,12 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
|||
@@rcconf = '/etc/rc.conf'
|
||||
@@rcconf_local = '/etc/rc.conf.local'
|
||||
|
||||
if Facter["operatingsystemrelease"].value == "4.9"
|
||||
@@pkg_scripts_var = "rc_scripts"
|
||||
else
|
||||
@@pkg_scripts_var = "pkg_scripts"
|
||||
end
|
||||
|
||||
def rcscript
|
||||
return File.join(@@rc_dir, @resource[:name])
|
||||
end
|
||||
|
@ -55,8 +61,8 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
|||
|
||||
def pkg_scripts
|
||||
File.open(@@rcconf_local).each do |line|
|
||||
if line =~ /^pkg_scripts=/
|
||||
return line.strip.gsub(/pkg_scripts="?([^"]*)"?/, '\1').split
|
||||
if line =~ /^#{@@pkg_scripts_var}=/
|
||||
return line.strip.gsub(/#{@@pkg_scripts_var}="?([^"]*)"?/, '\1').split
|
||||
end
|
||||
end
|
||||
Array.new
|
||||
|
@ -87,7 +93,7 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
|||
binary = @resource[:binary]
|
||||
s = ""
|
||||
File.open(@@rcconf_local).each do |line|
|
||||
next if line =~ /^(#{rcvar_name}|pkg_scripts)=/
|
||||
next if line =~ /^(#{rcvar_name}|#{@@pkg_scripts_var})=/
|
||||
s += line
|
||||
end
|
||||
unless start.nil?
|
||||
|
@ -103,7 +109,7 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
|||
s += "%s=YES\n" % rcvar_name
|
||||
end
|
||||
pkg_scripts << name if rcvar.nil? and not pkg_scripts.include?(name)
|
||||
s += "pkg_scripts=\"%s\"\n" % pkg_scripts.join(" ")
|
||||
s += "#{@@pkg_scripts_var}=\"%s\"\n" % pkg_scripts.join(" ")
|
||||
File.open(@@rcconf_local, "w") { |f| f << s }
|
||||
end
|
||||
|
||||
|
@ -114,12 +120,12 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
|||
pkg_scripts = self.pkg_scripts
|
||||
s = ""
|
||||
File.open(@@rcconf_local).each do |line|
|
||||
next if line =~ /^(#{rcvar_name}|pkg_scripts)=/
|
||||
next if line =~ /^(#{rcvar_name}|#{@@pkg_scripts_var})=/
|
||||
s += line
|
||||
end
|
||||
s += "%s=NO\n" % rcvar_name unless rcvar.nil?
|
||||
pkg_scripts.delete(name)
|
||||
s += "pkg_scripts=\"%s\"\n" % pkg_scripts.join(" ")
|
||||
s += "#{@@pkg_scripts_var}=\"%s\"\n" % pkg_scripts.join(" ")
|
||||
File.open(@@rcconf_local, "w") { |f| f << s }
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue