#!/bin/sh
# replaceear.sh etp-ear-file.ear oldstr newstr
# replace one of the parms in the ejb-jar.xml file within an ear

if [ "$#" != 3 ]; then
    echo "Usage:  $0 etp-ear-file.ear oldstr newstr"
    echo "        etp-ear-file.ear is a simple file in the current directory"
    echo "        the 'oldstr' is switched to 'newstr' within ejb-jar.xml"
    exit 1
fi

ear=$1
rm -rf tmp-ear new-$ear
mkdir tmp-ear
cd tmp-ear
jar xf ../$ear
mkdir ejb_settings
cd ejb_settings
jar xf ../ejb_settings.jar
cd META-INF
sed -e "s^$2^$3^g" <ejb-jar.xml >new.xml
mv new.xml ejb-jar.xml
cd ..
jar cfm ../ejb_settings.jar META-INF/MANIFEST.MF *
cd ..
rm -rf ejb_settings
jar cfm ../new-$ear META-INF/MANIFEST.MF *
cd ..
rm -rf tmp-ear

