def ok?
return false unless File.executable?("/usr/sbin/apache2")
output = []
config = self.generate_config(self.template)
tempfile = Tempfile.new(File.basename(self.filename))
tempfile.puts(config)
tempfile.close(false)
IO.popen( "/usr/sbin/apache2 -C 'UseCanonicalName off' -C 'Include /etc/apache2/mods-enabled/*.load' -C 'Include /etc/apache2/mods-enabled/*.conf' -f #{tempfile.path} -t 2>&1 ") {|io| output = io.readlines }
if "Syntax OK" == output.last.chomp
warn output.collect{|o| "\t"+o}.join.chomp if $VERBOSE
tempfile.unlink
return true
else
warn output.collect{|o| "\t"+o}.join.chomp
File.rename(tempfile.path, tempfile.path+".conf")
warn "\tTemporary config snippet retained at #{tempfile.path}.conf"
return false
end
end