HEX
Server: Apache
System: Linux server.enlacediseno.com 4.18.0-553.62.1.el8_10.x86_64 #1 SMP Wed Jul 16 04:08:25 EDT 2025 x86_64
User: maor (1069)
PHP: 7.3.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //var/lib/puppet/lib/facter/apache.rb
Facter.add("apache") do
	setcode do
		result = "false"

		# A bunch of boxes have shit apache installs with non-working, leftover apachectl's,
		# skipping /usr/sbin/apachectl for the time being.
		# We could also fix this later by correcting /usr/sbin/apachectl (maybe)

		#if FileTest.exists?("/usr/sbin/apachectl")
		#	result = "true"
		if FileTest.exists?("/usr/local/apache")
			result = "true"
		elsif FileTest.exists?("/usr/local/apache2")
			result = "true"
		end
		result
	end
end

Facter.add("apache_dir") do
    confine :apache => :true
    setcode do
	result = "false"
	#if FileTest.exists?("/usr/sbin/apachectl")
	#       result = %x{/usr/sbin/apachectl -V | grep HTTPD_ROOT | awk -F \\" \{'print $2'\}}.chomp
	if FileTest.exists?("/usr/local/apache/bin/httpd")
		output = %x{/usr/local/apache/bin/httpd -V | grep HTTPD_ROOT | cut -d \\" -f2}.chomp
		result = output
	elsif FileTest.exists?("/usr/local/apache2/bin/httpd")
		output = %x{/usr/local/apache2/bin/httpd -V | grep HTTPD_ROOT | cut -d \\" -f2}.chomp
		result = output
	end
	result
    end
end

Facter.add("apache_ver") do
	confine :apache => :true
	setcode do
		begin
			Facter.apache_dir
		rescue
			Facter.loadfacts()
		end
		main_dir = Facter.value('apache_dir')
		output = %x{#{main_dir}/bin/httpd -v | grep -vE 'built|Easy' | awk \{'print $3'\} | cut -d / -f2}.chomp
		result = output
	end
end