#!/bin/sh

if [ "$1" = "-T" ]; then
	echo -n "(c) ISPsystem.com"
	exit 0
fi

sbin/pkginstall.sh "$@"
exitcode=$?
if [ "$exitcode" = "0" ]; then
	echo "Checking PHP is alive" >> var/pkg.log
	/usr/bin/php -v 2>&1 >/dev/null
	exitcode=$?
	if [ "$exitcode" != "0" ]; then
		echo "It looks like PHP is a corpse, removing package $1" >> var/pkg.log
		sbin/pkgremove.sh $1
	else
		echo "PHP is ok" >> var/pkg.log
	fi
fi
exit $exitcode
