#!/bin/sh
  # Remove PHP3 from modules list
  if [ -f /usr/lib/apache/addons-list ] ; then
    awk < /usr/lib/apache/addons-list > /usr/lib/apache/addons-list- '
      { printed=0 }
      /^php$/ { printed=1 }
      (printed==0) { print $0 }
      '
    mv -f /usr/lib/apache/addons-list- /usr/lib/apache/addons-list
  fi
  if [ -f /usr/lib/apache/addons-list -a \
     ! -s /usr/lib/apache/addons-list ]; then
    rm -f /usr/lib/apache/addons-list
  fi
  # Remove PHP3 link from index.html
  if [ -f /home/httpd/html/index.html ] ; then
    INDEX_SUFFIX=html
  elif [ -f /home/httpd/html/index.shtml ] ; then
    INDEX_SUFFIX=shtml
  else
    unset INDEX_SUFFIX
  fi
  if test $INDEX_SUFFIX ; then
	mv -f /home/httpd/html/index.$INDEX_SUFFIX /home/httpd/html/index.$INDEX_SUFFIX--
        mv -f /home/httpd/html/index.$INDEX_SUFFIX- mv -f /home/httpd/html/index.$INDEX_SUFFIX
  fi

  if [ -f /etc/httpd/conf/httpd.conf ] ; then
    # Remove PHP3 icons & PHP3 extensions handling
    if grep -q '^\# PHP3 support$' /etc/httpd/conf/httpd.conf ; then
      awk < /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf- '
        BEGIN { needprint=1 }
        /\# PHP3 support/ { needprint=0 }
        /\# End of PHP3 support/ { needprint=2 }
        (needprint==1) { print $0 }
        (needprint==2) { needprint=1 }
        '
      mv -f /etc/httpd/conf/httpd.conf- /etc/httpd/conf/httpd.conf
    fi

    # Now change DirectoryIndex -- strip out index.php3 from there
    if grep -q '^ *DirectoryIndex.*index\.php3' /etc/httpd/conf/httpd.conf ; then
      sed 's/\(^ *DirectoryIndex\)\(.*\)\( index.php3\)/\1\2/' < /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf-
      mv -f /etc/httpd/conf/httpd.conf- /etc/httpd/conf/httpd.conf
    fi
  fi

  if [ -f /etc/httpd/conf/httpd.conf ] ; then
    # Exclude strings LoadModule & AddModule from httpd.conf
    awk < /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf- '
      { printed=0 }
      /.*LoadModule *php3_module/ { printed=1 }
      /.*AddModule *mod_php3/ { printed=1 }
      (printed==0) { print $0 }
      '
    mv -f /etc/httpd/conf/httpd.conf- /etc/httpd/conf/httpd.conf
  fi
