Module: Promotion::Generator::Rcconf
- Defined in:
- lib/promotion/generator/rcconf.rb
Class Method Summary collapse
-
.check(specs) ⇒ Object
Writes the system file /etc/rc.conf.local.
Class Method Details
.check(specs) ⇒ Object
Writes the system file /etc/rc.conf.local
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/promotion/generator/rcconf.rb', line 6 def self.check(specs) contents = IO.readlines("/etc/rc.conf.local").collect!{ |s| s.strip() } proposals = [] # Extract package scripts and sort them by increasing priority daemonSpecs = specs.reject {|s| s.elements["/Specification/Daemon"].nil? } daemonSpecs.sort!() { |a, b| ap = a.elements["/Specification/Daemon"].attributes["Priority"].to_i || 10 bp = b.elements["/Specification/Daemon"].attributes["Priority"].to_i || 10 ap <=> bp } pkgScripts = [] daemonSpecs.each { |spec| spec.each_element("Daemon") { |d| # allow for multiple daemons in a spec # Name defaults to the name of the spec, but may be overridden by the optional Name attribute name = d.attributes["Name"] || spec.attributes["Name"] flags = d.attributes["Flags"] needed = "#{name}_flags=\"#{flags}\"" proposals << needed unless contents.include?(needed.strip()) pkgScripts << name } } if proposals.size > 0 or contents.join("\n") !~ /pkg_scripts.*#{pkgScripts.join(" ")}/ puts("\nSuggested changes to /etc/rc.conf.local:", proposals.join("\n")) puts("\npkg_scripts=\"#{pkgScripts.join(" ")}\" ") puts("") end end |