#!/bin/sh
  # Remove mod_perl from modules list
  if [ -f /usr/libexec/httpd/addons-list ] ; then
    awk < /usr/libexec/httpd/addons-list > /usr/libexec/httpd/addons-list- '
      { printed=0 }
      /^perl$/ { printed=1 }
      (printed==0) { print $0 }
      '
    mv -f /usr/libexec/httpd/addons-list- /usr/libexec/httpd/addons-list
  fi
  if [ -f /usr/libexec/httpd/addons-list -a \
     ! -s /usr/libexec/httpd/addons-list ]; then
    rm -f /usr/libexec/httpd/addons-list
  fi
  # Remove mod_perl links from index.html's
  if [ -f /home/httpd/html/index.html ] ; then
    awk < /home/httpd/html/index.html > /home/httpd/html/index.html- '
      BEGIN { needprint=1 }
      /<!-- mod_perl site link -->/ { needprint=0 }
      /<!-- mod_perl site link end -->/ { needprint=2 }
      (needprint==1) { print $0 }
      (needprint==2) { needprint=1 }
      '
    mv -f /home/httpd/html/index.html- /home/httpd/html/index.html
  fi
  if [ -f /home/httpd/html/manual/mod/index.html ] ; then
    awk < /home/httpd/html/manual/mod/index.html > /home/httpd/html/manual/mod/index.html- '
      BEGIN { needprint=1 }
      /<!-- mod_perl documentation link -->/ { needprint=0 }
      /<!-- mod_perl documentation link end -->/ { needprint=2 }
      (needprint==1) { print $0 }
      (needprint==2) { needprint=1 }
      '
    mv -f /home/httpd/html/manual/mod/index.html- /home/httpd/html/manual/mod/index.html
  fi

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

    # Now change DirectoryIndex -- strip out index.PL from there
    if grep -q '^ *DirectoryIndex.*index\.PL' /etc/httpd/conf/srm.conf ; then
      sed 's/\(^ *DirectoryIndex\)\(.*\)\( index.PL\)/\1\2/' < /etc/httpd/conf/srm.conf > /etc/httpd/conf/srm.conf-
      mv -f /etc/httpd/conf/srm.conf- /etc/httpd/conf/srm.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 *perl_module/ { printed=1 }
      /.*AddModule *mod_perl/ { printed=1 }
      (printed==0) { print $0 }
      '
    mv -f /etc/httpd/conf/httpd.conf- /etc/httpd/conf/httpd.conf
  fi
