#!/bin/bash

MW_HOME=”/home/weblogic/Oracle/Middleware”
PATCH_FILE=”p33172858_1036_Generic.zip”
PATCH_TO_REMOVE=”21Y4″

# echo “Empty cache_dir”
rm -f ${MW_HOME}/utils/bsu/cache_dir/*

# echo “Download patch file”
wget http://10.1.1.1/weblogic/${PATCH_FILE}
unzip ${PATCH_FILE}

PATCH=`ls *.jar | cut -d’.’ –complement -f2-`
CATALOG=`ls patch-catalog*.xml`

# echo “Patch”
echo “PATCH=$PATCH”
echo “CATALOG=$CATALOG”

cp ${PATCH}.jar ${MW_HOME}/utils/bsu/cache_dir/.
cp ${CATALOG} ${MW_HOME}/utils/bsu/cache_dir/patch-catalog.xml

cd ${MW_HOME}/utils/bsu
#./bsu.sh -view -status=applied -prod_dir=${MW_HOME}/wlserver_10.3

if [ -n “$PATCH_TO_REMOVE” ]; then
${MW_HOME}/utils/bsu/bsu.sh -remove -prod_dir=${MW_HOME}/wlserver_10.3 -patchlist=${PATCH_TO_REMOVE} -verbose
fi

${MW_HOME}/utils/bsu/bsu.sh -prod_dir=${MW_HOME}/wlserver_10.3 -patchlist=${PATCH} -verbose -install

. ${MW_HOME}/wlserver_10.3/server/bin/setWLSEnv.sh
java weblogic.version