#!/bin/sh
	tmp_file="httpd.$$"

	sed '/Directory.*www\/html/,/\/Directory/s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf > $tmp_file
	cat $tmp_file > /etc/httpd/conf/httpd.conf
	diff $tmp_file /etc/httpd/conf/httpd.conf >/dev/null 2>&1
	if [ $? -eq 0 ]; then
        	rm -rf $tmp_file
	fi

	mv -f /var/www/html/ /var/www/html_old	
	mkdir -p /var/www/html

	chmod -R og-w /var/www/html

	cd /usr/local/frontpage/version5.0/
	
	sh /usr/local/frontpage/version5.0/set_default_perms.sh

    #setting up front page extension for main webserver
    /usr/local/frontpage/currentversion/bin/owsadm.exe -o install -p 80 -servconf "/etc/httpd/conf/httpd.conf" -u fpuser -pw test -xUser fpweb -xGroup fpweb > /usr/local/frontpage/frontpage-install.log 2> /usr/local/frontpage/frontpage-install.err

	rm -rf /usr/local/frontpage/frontpage-install.*

    # this is done because it seems like sometimes owsadm will chmod things improperly and then things don't work so this is done to make sure
    # things will run correctly with the right permissions when you actually go use front page. 
    	cd /var/www/html
    	chmod -R g-w * 
	chmod -R g-w .*

	chown -R fpweb:fpweb /var/www/html/_vti*
	chown -R fpweb:fpweb /var/www/html/_private
	chown -R fpweb:fpweb /var/www/html/.htaccess

	cp -prf /var/www/html_old/* /var/www/html
	rm -rf /var/www/html_old

	/etc/rc.d/init.d/httpd restart
	sleep 2
exit 0
