使用shell 一次执行,将项目中的war包的配置全部修改
#!/bin/bash #----------------------------------------------- # FileName: deployWAR.sh # Reversion: 1.5 # Date: // # Author: zhengwenqiang # Email: zhengwenqiang@bonc.com.cn # Description: change the properties of the essential configuration file, it means that before you startup tomcat to run those three apps etc cas,portal,security # it's vital to run this script which bring the proccess running normally. # Notes: If you are going execute this script on linux, you should run the command "sed -i 's/\r//g' getwar.sh" # to delete invalid character which cause character error. # Changes: solve the error caused by default-schema configuration. # Copyright: (c) zhengwenqiang # License: GPL #----------------------------------------------- #cd `)` # configure Cas conf='conf.properties' ] ; then conf=$ fi if [ -f $conf ] ; then #cat -A conf.properties | grep -E -v '^\^?M' | sed 's/\^M\$$//g'>conf.sh #cat conf.properties | grep -E -v '^\^?M' | tr -d '\r' | tee conf.sh [ -f conf.sh ] && rm -f conf.sh cat $conf | grep -E -v '^\^?M' | tr -d '\r'>conf.sh chmod u+x,u+w conf.sh sed -i '1i \#\!\/bin\/bash' conf.sh && chmod u-w conf.sh source conf.sh else echo "conf.properties not found">install.log exit ; fi if [ -z $cas_ip ] ; then # cas_ip=`ip addr | tr -d 'inet '` cas_ip=`ip addr show | | sed 's/[^0-9\.]//g'` fi if [ -z $security_ip ] ; then security_ip=$cas_ip fi if [ -z $portal_ip ] ; then portal_ip=$security_ip fi cd webapps if [ $casEnable == "true" ] ; then [ -d cas ] && rm -rf cas cas_war=`` if [ -f ${cas_war} ] ; then mkdir cas && unzip ${cas_war} -d cas cas_pros='cas/WEB-INF/cas.properties' sed -i "s/CAS_IP:CAS_PORT/${cas_ip}:${cas_port}/g" ${cas_pros} sed -i "s/PORTAL_IP:PORTAL_PORT/${portal_ip}:${portal_port}/g" ${cas_pros} sed -i "s/SE_IP:SE_PORT/${security_ip}:${security_port}/g" ${cas_pros} cas/WEB-INF/classes/bonc-security-base.properties sed -r "s/DB_IP:DB_PORT([/:])DB_NAME/${db_ip}:${db_port}\1${db_name}/g" -i ${cas_pros} case $db_type in "mysql") sed -r '/MySQLDialect\r?$/s/^#//g' -i ${cas_pros} sed -r '/com.bonc.jdbc.MysqlDriver$/,+3s/^#//g' -i ${cas_pros} sed -r '/com.mysql.jdbc.Driver$/,+3s/^#//g' -i ${cas_pros} ;; "oracle") sed -r '/Oracle10gDialect\r?$/s/^#//g' -i ${cas_pros} sed -r '/com.bonc.jdbc.OracleDriver$/,+4s/^#//g' -i ${cas_pros} sed -r '/oracle.jdbc.driver.OracleDriver$/,+4s/^#//g' -i ${cas_pros} ;; *) ;; esac sed -i "s/DB_USERNAME/${db_username}/g" ${cas_pros} sed -i "s/DB_PASSWD/${db_passwd}/g" ${cas_pros} unset ${cas_pros} fi [ ${cas_war} != "cas.war" ] && mv ${cas_war} cas.war fi if [ $portalEnable == "true" ] ; then # Configure Portal [ -d portal ] && rm -rf portal portal_war=`` if [ -f ${portal_war} ] ; then mkdir portal && unzip ${portal_war} -d portal for portal in 'portal/WEB-INF/web.xml' 'portal/WEB-INF/classes/bonc-security-base.properties' 'portal/WEB-INF/classes/cfg.db.deploy.properties' do sed -i "s/CAS_IP:CAS_PORT/${cas_ip}:${cas_port}/g" $portal sed -i "s/PORTAL_IP:PORTAL_PORT/${portal_ip}:${portal_port}/g" $portal sed -i "s/SE_IP:SE_PORT/${security_ip}:${security_port}/g" $portal sed -r "s/DB_IP:DB_PORT([/:])DB_NAME/${db_ip}:${db_port}\1${db_name}/g" -i $portal sed -i "s/DB_USERNAME/${db_username}/g" $portal sed -i "s/DB_PASSWD/${db_passwd}/g" $portal done case $db_type in "mysql") sed -r '/^#?database.type=mysql$/,+4s/^#//g' -i 'portal/WEB-INF/classes/cfg.db.deploy.properties' sed -r '/MySQL5Dialect$/s/^#//g' -i 'portal/WEB-INF/classes/cfg.db.deploy.properties' sed -i "s/DB_SCHEMA/${db_name}/g" 'portal/WEB-INF/classes/cfg.db.deploy.properties' ;; "oracle") sed -r '/^#?database.type=oracle$/,+5s/^#//g' -i 'portal/WEB-INF/classes/cfg.db.deploy.properties' sed -r '/Oracle10gDialect$/s/^#//g' -i 'portal/WEB-INF/classes/cfg.db.deploy.properties' sed -i "s/DB_SCHEMA/${db_username}/g" 'portal/WEB-INF/classes/cfg.db.deploy.properties' ;; *) ;; esac fi fi # Configure Security if [ $securityEnable == "true" ] ; then [ -d security ] && rm -rf security security_war=`` if [ -f ${security_war} ] ; then mkdir security && unzip ${security_war} -d security for security in 'security/WEB-INF/web.xml' 'security/WEB-INF/classes/bonc-security-base.properties' 'security/WEB-INF/classes/cfg.db.deploy.properties' 'security/WEB-INF/classes/bonc-security.properties' do sed -i "s/CAS_IP:CAS_PORT/${cas_ip}:${cas_port}/g" $security sed -i "s/SE_IP:SE_PORT/${security_ip}:${security_port}/g" $security sed -r "s/DB_IP:DB_PORT([/:])DB_NAME/${db_ip}:${db_port}\1${db_name}/g" -i $security sed -i "s/DB_USERNAME/${db_username}/g" $security sed -i "s/DB_PASSWD/${db_passwd}/g" $security done case $db_type in "mysql") sed -r '/^#?database.type=mysql$/,+4s/^#//g' -i 'security/WEB-INF/classes/cfg.db.deploy.properties' sed -r '/MySQL5Dialect$/s/^#//g' -i 'security/WEB-INF/classes/cfg.db.deploy.properties' sed -r '/^#?database.type=mysql$/,+4s/^#//g' -i 'security/WEB-INF/classes/bonc-security.properties' sed -i "s/DB_SCHEMA/${db_name}/g" 'security/WEB-INF/classes/cfg.db.deploy.properties' ;; "oracle") sed -r '/^#?database.type=oracle$/,+5s/^#//g' -i 'security/WEB-INF/classes/cfg.db.deploy.properties' sed -r '/Oracle10gDialect$/s/^#//g' -i 'security/WEB-INF/classes/cfg.db.deploy.properties' sed -r '/^#?database.type=oracle$/,+4s/^#//g' -i 'security/WEB-INF/classes/bonc-security.properties' sed -i "s/DB_SCHEMA/${db_username}/g" 'security/WEB-INF/classes/cfg.db.deploy.properties' ;; *) ;; esac fi fi