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 = '/etc/rc.conf'
|
||||||
@@rcconf_local = '/etc/rc.conf.local'
|
@@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
|
def rcscript
|
||||||
return File.join(@@rc_dir, @resource[:name])
|
return File.join(@@rc_dir, @resource[:name])
|
||||||
end
|
end
|
||||||
|
@ -55,8 +61,8 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
||||||
|
|
||||||
def pkg_scripts
|
def pkg_scripts
|
||||||
File.open(@@rcconf_local).each do |line|
|
File.open(@@rcconf_local).each do |line|
|
||||||
if line =~ /^pkg_scripts=/
|
if line =~ /^#{@@pkg_scripts_var}=/
|
||||||
return line.strip.gsub(/pkg_scripts="?([^"]*)"?/, '\1').split
|
return line.strip.gsub(/#{@@pkg_scripts_var}="?([^"]*)"?/, '\1').split
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Array.new
|
Array.new
|
||||||
|
@ -87,7 +93,7 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
||||||
binary = @resource[:binary]
|
binary = @resource[:binary]
|
||||||
s = ""
|
s = ""
|
||||||
File.open(@@rcconf_local).each do |line|
|
File.open(@@rcconf_local).each do |line|
|
||||||
next if line =~ /^(#{rcvar_name}|pkg_scripts)=/
|
next if line =~ /^(#{rcvar_name}|#{@@pkg_scripts_var})=/
|
||||||
s += line
|
s += line
|
||||||
end
|
end
|
||||||
unless start.nil?
|
unless start.nil?
|
||||||
|
@ -103,7 +109,7 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
||||||
s += "%s=YES\n" % rcvar_name
|
s += "%s=YES\n" % rcvar_name
|
||||||
end
|
end
|
||||||
pkg_scripts << name if rcvar.nil? and not pkg_scripts.include?(name)
|
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 }
|
File.open(@@rcconf_local, "w") { |f| f << s }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -114,12 +120,12 @@ Puppet::Type.type(:service).provide :openbsd, :parent => :base do
|
||||||
pkg_scripts = self.pkg_scripts
|
pkg_scripts = self.pkg_scripts
|
||||||
s = ""
|
s = ""
|
||||||
File.open(@@rcconf_local).each do |line|
|
File.open(@@rcconf_local).each do |line|
|
||||||
next if line =~ /^(#{rcvar_name}|pkg_scripts)=/
|
next if line =~ /^(#{rcvar_name}|#{@@pkg_scripts_var})=/
|
||||||
s += line
|
s += line
|
||||||
end
|
end
|
||||||
s += "%s=NO\n" % rcvar_name unless rcvar.nil?
|
s += "%s=NO\n" % rcvar_name unless rcvar.nil?
|
||||||
pkg_scripts.delete(name)
|
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 }
|
File.open(@@rcconf_local, "w") { |f| f << s }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue