linux 补丁脚本,Linux上打patch补丁包脚本全解

0818b9ca8b590ca3270a3433284dd417.png今天我又要展示一样重要的技术--在Linux上写patch脚本,话不多说,且看:

一 、 首先要打的包肯定是回滚事物包, 就是BackUp包, 在我们要打补丁前当然要备份服务器上的数据,不然出了问题, 手都不知道放哪了, 太紧张!!!

二 、在做好了退路后, 我们就要打部署包, 就是deploy包, 我们要把更新的内容发布到server上, 不然如何叫更新呢。。。

三、 在写好了deploy包后, 就要写回滚包, 就是RollBack包,万一出了问题, 在回滚到先前的版本,尝试啊!!!

四、 我们需要一个定义一个全局变量的脚本setVariebles, 因为服务器的路径很多,可以定义成简单的路径,然后引用,就像java的常量定义一样。

好的,相信大家都明白了大的套路和步骤,下面我将以本人最近写的patch脚本为实例一一详解其机制原理:

set_variebles

##########################################

##### Directory Structure

##########################################

SRC_HOME=/var/opt/swdepot/prod

RELEASE_NUM=7_11

RELEASE=pdapi$RELEASE_NUM

PRE_HOME=$SRC_HOME/presentation

PRE_RELEASE_HOME=$PRE_HOME/$RELEASE

PRE_CURRENT_HOME=$PRE_HOME/current

##### Presentation related entries

DATALOAD_HOME=$PRE_CURRENT_HOME/dataload

ECOMMERCE_HOME=$PRE_CURRENT_HOME/ecommerce

IMT_HOME=$PRE_CURRENT_HOME/imt

OPENSOURCE_HOME=$PRE_CURRENT_HOME/opensource

PAYMENT_HOME=$PRE_CURRENT_HOME/payment

PORTAL_HOME=$PRE_CURRENT_HOME/portal

TEST_HOME=$PRE_CURRENT_HOME/test

##### Txn server related entries

TXN_HOME=$SRC_HOME/txn_server

TXN_RELEASE_HOME=$TXN_HOME/$RELEASE

TXN_CURRENT_HOME=$TXN_HOME/current

TXN_4000=$TXN_CURRENT_HOME/4000

##### Webservice related entries

WS_HOME=$SRC_HOME/webservices

WS_RELEASE_HOME=$WS_HOME/$RELEASE

WS_CURRENT_HOME=$WS_HOME/current

##### BO related entries

BO_SRC_HOME=/opt/sasuapps/pdapi/pdapirpt

BO_CONF_HOME=$BO_SRC_HOME/conf

BO_TEMPLATE_HOME=$BO_SRC_HOME/template

##### DB INI Config

DBFACTORY_HOME=$SRC_HOME/db

# Generate the date in MMDDYYYY.24hrTime format

DATE=$(date +"%Y%m%d%T")

DATE2=$(date +"%d%b")

##### Application patch directory

PDAPI_HOME=/opt/sasuapps/pdapi

PATCHES_HOME=$PDAPI_HOME/patches/pdapi7_11_1_MTP

BACKUP_DIR=$PATCHES_HOME/backup

##### Weblogic domain home

##### Austin PROD - Uncomment entry for Austin PROD!!!!!!!

##### WEBLOGIC_DOMAIN_HOME=$PDAPI_HOME/domain/pdapi

##### Austin ITG

WEBLOGIC_DOMAIN_HOME=$PDAPI_HOME/domain/pdapi-itg

##### Weblogic scripts

WEBLOGIC_WLST=$PDAPI_HOME/patches/weblogic_wlst

##### BO patch directory

BO_PATCHES_HOME=$PATCHES_HOME/BO

BO_BACKUP_DIR=$BO_PATCHES_HOME/backup

##### DB sql patch directory

SQL_PATCHES_HOME=$PATCHES_HOME/sql

##### Application LOGS

##### Austin PROD only (uncomment for PROD!!!!!!!)

#TXN_LOGS=/home/ftp/LOGS/txn_server

#PRE_LOGS=/home/ftp/LOGS/presentation

##### Austin ITG only

TXN_LOGS=/home/ftp/LOGS/itg/txn_server

PRE_LOGS=/home/ftp/LOGS/itg/presentation

backup.sh

#!/usr/bin/ksh

##########################################

##### Directory Structure

##########################################

. ./set_variables

##########################################

##### Backup

##########################################

echo "backup swdepot"

mkdir $BACKUP_DIR

cp -f $PORTAL_HOME/WEB-INF/services/swdepot/properties/error_messages_de.properties $BACKUP_DIR

cp -f $PORTAL_HOME/WEB-INF/services/swdepot/properties/swdepot_de.properties $BACKUP_DIR

###add survey  ###

cp -f $PORTAL_HOME/swdepot/jsp/try.jsp $BACKUP_DIR

cp -f $PORTAL_HOME/WEB-INF/classes/com/hp/wwops/ecommerce/presentation/portals/swdepot/action/ProcessTrialOrder.class $BACKUP_DIR

cp -f $PORTAL_HOME/WEB-INF/services/swdepot/properties/swdepot.properties $BACKUP_DIR

###add survey  ###

### add Eula ###

cp -f $PORTAL_HOME/swdepot/html/disclaimer.html $BACKUP_DIR

cp -f $PORTAL_HOME/swdepot/html/free-disclaimer.html $BACKUP_DIR

cp -f $PORTAL_HOME/swdepot/html/trial-disclaimer.html $BACKUP_DIR

cp -f $ECOMMERCE_HOME/common/html/EN_TS_PRMO.html $BACKUP_DIR

cp -f $ECOMMERCE_HOME/common/html/EN_TS.html $BACKUP_DIR

cp -f $ECOMMERCE_HOME/common/html/US_TS_PRMO.html $BACKUP_DIR

cp -f $ECOMMERCE_HOME/common/html/US_TS.html $BACKUP_DIR

### add Eula ###

deploy.sh

#!/usr/bin/ksh

##########################################

##### Directory structure/variables

##########################################

. ./set_variables

##########################################

##### backup

##########################################

echo "Backup files...."

./backup.sh

##########################################

##### Validate

##########################################

echo "Validate begin...Txn Server, WS, Presentation"

./validate.sh

##########################################

##### Deploy

##########################################

echo "Deploy Txn Server, WS, Presentation"

cp -f $PATCHES_HOME/error_messages_de.properties $PORTAL_HOME/WEB-INF/services/swdepot/properties/

cp -f $PATCHES_HOME/swdepot_de.properties $PORTAL_HOME/WEB-INF/services/swdepot/properties/

###add survey ###

cp -f $PATCHES_HOME/try.jsp  $PORTAL_HOME/swdepot/jsp/

cp -f $PATCHES_HOME/ProcessTrialOrder.class $PORTAL_HOME/WEB-INF/classes/com/hp/wwops/ecommerce/presentation/portals/swdepot/action/

cp -f $PATCHES_HOME/swdepot.properties $PORTAL_HOME/WEB-INF/services/swdepot/properties/

###add survey ###

###add  Eula ###

cp -f $PATCHES_HOME/disclaimer.html $PORTAL_HOME/swdepot/html/

cp -f $PATCHES_HOME/free-disclaimer.html $PORTAL_HOME/swdepot/html/

cp -f $PATCHES_HOME/trial-disclaimer.html $PORTAL_HOME/swdepot/html/

cp -f $PATCHES_HOME/EN_TS_PRMO.html $ECOMMERCE_HOME/common/html/

cp -f $PATCHES_HOME/EN_TS.html $ECOMMERCE_HOME/common/html/

cp -f $PATCHES_HOME/US_TS_PRMO.html $ECOMMERCE_HOME/common/html/

cp -f $PATCHES_HOME/US_TS.html $ECOMMERCE_HOME/common/html/

###add  Eula ###

##########################################

##### Validate

##########################################

echo "Validate begin...Txn Server, WS, Presentation"

./validate.sh

rollback.sh

##########################################

##### Directory Structure

##########################################

. ./set_variables

##########################################

##### Rollback

##########################################

echo "Rollback begin...Txn Server"

./validate.sh

cp -f $BACKUP_DIR/error_messages_de.properties $PORTAL_HOME/WEB-INF/services/swdepot/properties/

cp -f $BACKUP_DIR/swdepot_de.properties $PORTAL_HOME/WEB-INF/services/swdepot/properties/

###add survey ###

cp -f $BACKUP_DIR/try.jsp  $PORTAL_HOME/swdepot/jsp/

cp -f $BACKUP_DIR/ProcessTrialOrder.class $PORTAL_HOME/WEB-INF/classes/com/hp/wwops/ecommerce/presentation/portals/swdepot/action/

cp -f $BACKUP_DIR/swdepot.properties $PORTAL_HOME/WEB-INF/services/swdepot/properties/

###add survey ###

###add  Eula ###

cp -f $BACKUP_DIR/disclaimer.html $PORTAL_HOME/swdepot/html/

cp -f $BACKUP_DIR/free-disclaimer.html $PORTAL_HOME/swdepot/html/

cp -f $BACKUP_DIR/trial-disclaimer.html $PORTAL_HOME/swdepot/html/

cp -f $BACKUP_DIR/EN_TS_PRMO.html $ECOMMERCE_HOME/common/html/

cp -f $BACKUP_DIR/EN_TS.html $ECOMMERCE_HOME/common/html/

cp -f $BACKUP_DIR/US_TS_PRMO.html $ECOMMERCE_HOME/common/html/

cp -f $BACKUP_DIR/US_TS.html $ECOMMERCE_HOME/common/html/

###add  Eula ###

echo "Rollback Weblogic apps"

./wl_update_apps.sh

echo "Rollback finished"

以上就是全部的Linux脚本了,至于里面的什么命令的不懂的,请上网参看Linux vi命令, 或者也可以参考我的Blog里面的Linux命令详解。

Any question , welcome email to      【 zhe-jiang.he@hp.com】!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值