#!/bin/sh
#
# Little script to add xalan to jserv configuration
#
# v0.2 2000-02-24 Henri Gomez <gomez@slib.fr>
#
# From work of Murray Todd Williams <MurrayTodd@yahoo.com>
#

#
# Update jserv.properties if existing
#
if [ -f /etc/httpd/conf/jserv/jserv.properties ] ; then

    # remove xalan.jar/bsf.jar/bsfengines.jar if any
    sed -e '/^wrapper.classpath=\/opt\/xalan-j\/bsf[^.]*.jar/d' \
    -e '/^wrapper.classpath=\/opt\/xalan-j\/xalan.jar/d' \
    < /etc/httpd/conf/jserv/jserv.properties \
    > /etc/httpd/conf/jserv/jserv.properties.new
    mv /etc/httpd/conf/jserv/jserv.properties.new \
       /etc/httpd/conf/jserv/jserv.properties

    grep "^wrapper.classpath=" /etc/httpd/conf/jserv/jserv.properties \
	>/dev/null
    if test $? -eq 0 ; then
	( echo "?^wrapper.classpath="
	  echo "a"
	  echo "wrapper.classpath=/opt/xalan-j/xalan.jar"
	  echo "wrapper.classpath=/opt/xalan-j/bsf.jar"
	  echo "wrapper.classpath=/opt/xalan-j/bsfengines.jar"
	  echo "."
	  echo "wq"
        ) | ed /etc/httpd/conf/jserv/jserv.properties >/dev/null 2>&1
    else
	( echo "/^#.*Syntax.*wrapper-classpath"
	  echo "/^[^#]"
	  echo "a"
	  echo "wrapper.classpath=/opt/xalan-j/xalan.jar"
	  echo "wrapper.classpath=/opt/xalan-j/bsf.jar"
	  echo "wrapper.classpath=/opt/xalan-j/bsfengines.jar"
	  echo "."
          echo "wq"
	) | ed /etc/httpd/conf/jserv/jserv.properties >/dev/null 2>&1
    fi
fi
