#!/bin/sh

while [ 1 ] ; do

echo Press the number:
echo 1. Install PHP package
echo 2. Uninstall PHP package
echo 3. Exit.

read A

if [ "$A" == "1" ] ; then
	echo Start to install PHP. Please wait ...
	killall httpd 2> /dev/null
	sleep 1
	if ! [ -d /home/php ]; then
		mkdir /home/php
	fi
	if ! [ -d /home/php/lib ]; then
		mkdir /home/php/lib
	fi
	cp -a ./lib/* /home/php/lib 2> /dev/null
	cp ./httpd.conf /etc/apache/conf/httpd.conf 2> /dev/null
	cp ./envvars /etc/apache/envvars 2> /dev/null
	cp -a ./php /etc/apache 2> /dev/null
	cp ./phpinfo.php /home/httpd/htdocs 2> /dev/null
	/etc/init.d/apache start
	echo PHP install sucess.
	break;
fi

if [ "$A" == "2" ] ; then
	echo Start to uninstall PHP. Please wait ...
	killall httpd > /dev/null
	sleep 1
	rm -fr /home/php 2> /dev/null
	rm -fr /etc/apache/php 2> /dev/null
	rm -f /home/httpd/htdocs/phpinfo.php 2> /dev/null
	cp ./httpd.conf.old /etc/apache/conf/httpd.conf 2> /dev/null
	cp ./envvars.old /etc/apache/envvars 2> /dev/null
	/etc/init.d/apache start
	echo PHP uninstall sucess.
	break;
fi

if [ "$A" == "3" ] ; then
	break;
fi

done
