#!/bin/sh -e
#
# Test if PHP is working

# We do not use PHP any more [pere 2005-12-02]
exit 0

if test -r /etc/debian-edu/config ; then
    . /etc/debian-edu/config
fi

# Only Main-Server should use PHP
if echo "$PROFILE" | grep -q Main-Server ; then
    :
else
    exit 0
fi

testfile=/home/www/test.php
url=http://www.intern/test.php

unset http_proxy || true
unset ftp_proxy  || true

if [ ! -x /usr/bin/GET ] ; then
    echo "error: $0: Unable to find /usr/bin/GET."
    exit 1
else
    cat <<EOF > "$testfile"
<html>
  <head>
    <title>Min første PHP-side</title>
  </head>
  <body>
n    <?php echo "Hello World<p>"; ?>
  </body>
</html>
EOF
    chmod a+rx "$testfile"

    if /usr/bin/GET "$url" 2>/dev/null | grep -q 'Hello World' ; then
	echo "success: $0: PHP script executed as it should."
        rm -f "$testfile"
    else
	echo "error: $0: PHP script gave incorrect output or failed to run."
        rm -f "$testfile"
	exit 1
    fi
fi

exit 0
