Linux上打patch補丁包腳本全解

羨慕今天我又要展示一樣重要的技術--在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      【 [email protected]】!

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章