###############################################################################
#
# Open iT Patch definition
#


# Stop reporting server
stop
{
	error=warning
	module=reportingserver
}

# Wait for all previously signalled programs to stop
waitstop
{
	error=fatal
	timeout=60
	kill=no
}

# Install PHP files
installfromdir
{
	error=fatal
	source=web/php/
	target=%installdir%/ReportingServer/
}

# Install Perl files
installfromdir
{
	error=fatal
	source=web/lib
	target=%installdir%/lib/
}

# Run oms script to remove swf and phpinfo files
run
{
	error=fatal
	source=remove_swf.oms
	timeout=60
}

# Install Apache 2.4.x binaries
installfromdir
{
	error=fatal
	source=bin/apache/
	target=%installdir%/External/Apache/
}


# Install PHP 5.6.x binaries
installfromdir
{
	error=fatal
	source=bin/php/
	target=%installdir%/External/PHP/
}

linepatch
{
	error=warning
	target=%confdir%\httpd\httpd.conf
	instr1=home
	instr2=find *mod_rewrite.so*
	instr3=insert LoadModule headers_module modules/mod_headers.so
	instr4=find *mod_headers.so*
	instr5=insert LoadModule reqtimeout_module modules/mod_reqtimeout.so
	instr6=find *Order allow,deny*
	instr7=remove
	instr8=find *# Uncomment below configuration if ssl is needed.*
	instr9=rinsert <IfModule headers_module>
	instr10=insert 	Header set X-XSS-Protection "1; mode=block"
	instr11=insert 	Header always append X-Frame-Options SAMEORIGIN
	instr12=insert </IfModule>
	instr13=insert
	instr14=insert TraceEnable Off
	instr15=insert
	instr16=insert <IfModule reqtimeout_module>
	instr17=insert 	RequestReadTimeout header=20-50,MinRate=500 body=20,MinRate=500
	instr18=insert </IfModule>
	instr19=insert
	instr20=end
	instr21=seek -1
	instr22=replace #Include ../../Configuration/httpd/httpd-ssl.conf
}
elselinepatch
{
	error=warning
	target=%confdir%\httpd\httpd.conf
	instr1=home
	instr2=find *ServerRoot*
}

# Install HTTPS files
installfromdir
{
	error=fatal
	source=conf\httpd\
	target=%installdir%/Configuration/httpd
}

linepatch
{
	error=warning
	target=%confdir%\httpd\httpd-ssl.conf
	instr1=find *SSLMutex default*
	instr2=remove
	instr3=find *SSLProtocol all -SSLv2*
	instr4=replace SSLProtocol all -SSLv2 -SSLv3
}
elselinepatch
{
	error=warning
	target=%confdir%\httpd\httpd-ssl.conf
	instr1=home
	instr2=find *Listen*
}

# Set default timeout to 10 hours. Copy the configuration used for UCS

linepatch
{
	error=warning
	target=%confdir%\httpd\httpd.conf
	instr1=home
	instr2=find *Timeout 36000*
	instr3=remove
	instr4=find *KeepAlive On*
	instr5=remove
	instr6=find *MaxKeepAliveRequests 100*
	instr7=remove
	instr8=find *KeepAliveTimeout 15*
	instr9=remove
	instr10find *RequestReadTimeout*
	instr11=rinsert 	KeepAliveTimeout 15
	instr12=rinsert 	MaxKeepAliveRequests 100
	instr13=rinsert 	KeepAlive On
	instr14=rinsert 	Timeout 36000
}
elselinepatch
{
	error=warning
	target=%confdir%\httpd\httpd.conf
	instr1=home
	instr2=find *RequestReadTimeout*
	instr3=rinsert 	KeepAliveTimeout 15
	instr4=rinsert 	MaxKeepAliveRequests 100
	instr5=rinsert 	KeepAlive On
	instr6=rinsert 	Timeout 36000
}

# Start reportingserver
start
{
	error=warning
	module=reportingserver
}