begin
require 'cfpropertylist'
Executable = '/usr/sbin/httpd'
EnvPlistPath = '/etc/apache2/env.plist'
args = ARGV
if FileTest.exists?(EnvPlistPath)
envPlist = CFPropertyList::List.new(:file => EnvPlistPath)
envDict = CFPropertyList.native_types(envPlist.value)
envDict.each do |key, value|
if key.start_with? '-D'
args.unshift(key)
else
ENV[key] = value
end
end
end
exec("#{Executable} #{ARGV.join(' ')}")
rescue => e
require 'logger'
$logger = Logger.new('/var/log/apache2/httpd-wrapper.log')
$logger.level = Logger::ERROR
$logger.error("Exception raised running #{$0}: #{e.message}")
$logger.error("Proceeding with exec of #{Executable}")
exec("#{Executable} #{ARGV.join(' ')}")
end