#!/bin/bash
export ORACLE_HOME=/home/weblogic/Oracle/Middleware/Oracle_Home
OP_PACH=${ORACLE_HOME}/OPatch
PKG_PATCH=ftp://10.1.1.1/patch/weblogic/12.1.3
PKG_NAME=p33172866_121300_Generic.zip
linshi=/home/weblogic/patch

# 创建新文件夹
if [[ -d ${linshi} ]];then
rm -rf ${linshi}
else
mkdir -p ${linshi}
fi

# 获取补丁包
cd ${linshi} && curl -o ./${PKG_NAME} ${PKG_PATCH}/${PKG_NAME}

# 解压
which unzip &> /dev/null
if [[ $? -eq 0 ]];then
unzip ${linshi}/*.zip -d ${linshi};
else
echo “unzip is not exsits, yum install it first, plz”
fi

# 停止weblogic服务
ps -ef | grep java| grep weblogic | grep -v “grep” &> /dev/null
if [[ $? -eq 0 ]];then
ps -ef |grep java| grep weblogic | grep -v “grep”|awk ‘{print $2}’|xargs kill -9
else
echo “weblogic process is not exsits”
fi

# 打补丁
PKG_NAME=$(cd ${linshi} && ls | grep -Ev ‘*.zip’)
cd ${linshi}/${PKG_NAME} && ${OP_PACH}/opatch apply -silent

# 启动weblogic
#nohup ${ORACLE_HOME}/user_projects/domains/base_domain/startWebLogic.sh &