使用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

【Tomcat】shell 部署配置 war包的更多相关文章

  1. Docker实现运行tomcat并部署项目war包,并实现挂载目录

    之前写的有点乱,现在再来整理一下docker的简单部署运行 借鉴博客:https://blog.csdn.net/qq_32351227/article/details/78673591 一.dock ...

  2. Spring Boot取消默认tomcat启动,打成war包发布到服务器运行

    一.设置打包方式 在pom.xml中设置打包格式 <packaging>war</packaging> 二.取消Spring Boot的tomcat <!--部署成war ...

  3. intellij idea tomcat 启动不生成war包

    intellij idea tomcat 启动不生成war包 想把项目打包成war包做测试,但是按照之前的方法居然没有成功导出war包,犯了很低级的错误,特此记录. (1)首先在Project Str ...

  4. Tomcat上进行项目部署与WAR包含义

    一.WAR包 1.与JAR包类似,是将java类(编译好的.class)和Web资源,压缩后生成压缩包. 2. 与JAR相比,多了WEB-INF文件夹,其它多出来的内容基本都是Web资源 WEB-IN ...

  5. Tomcat访问控制及站点部署(以WAR包形式上传)!(重点)

    访问控制 首先安装好jdk以及apache-tomcat并能访问tomcat网页 点击server status了解服务状态会报403的错误 第一步:修改user.xml配置文件 [root@loca ...

  6. tomcat运行springboot项目war包

    以最简单的spring boot demo项目来演示如何发布项目war包到tomcat,并成功运行(有很多小伙伴会出现404错误) 一.准备一个最简单的demo项目 在IDEA中新建一个项目,一直ne ...

  7. springboot项目部署(war包)

    将springboot项目打包成war,并且部署到tomcat.比较麻烦,自己踩的坑也比较多.算了一下,找bug的时间,有两天熬到凌晨2点. 修改pom.xml使得打包成war <groupId ...

  8. Spring Boot 2 构建可部署的war包

    默认情况下Spring Boot使用了内嵌的Tomcat服务器,项目最终被打成jar包运行,每个jar包可以被看作一个独立的Web服务器.传统的Web开发,一般会将Web应用打成一个war包,然后将其 ...

  9. linux中部署jenkins(war包)及jenkins忘记登录账号密码

    未登录状态 登录状态 一:部署jenkins(war包) 1.直接下载war包jenkins.war,下载地址https://jenkins.io/download 2.将下载的war包放到服务器上t ...

随机推荐

  1. JavaScript+svg绘制的一个饼状图

    结果: svg参考:https://www.w3.org/TR/SVG/<body onload='document.body.appendChild( pieChart([12,23,34,4 ...

  2. Android之ListView优化

    关于ListView几个方面的优化: ListView的大小设定固定值; 复用convertView, 使用ViewHolder提高在容器中查找组件的效率; 使用分页加载; 快速滚动时, item不显 ...

  3. C++学习(五)入门篇——基本类型

    面向对象编程的本质是设计并扩展自己的数据类型,让类型和数据匹配. 内置C++分成两种类型:基本类型和复合类型 1.简单变量 程序需要存储信息时,必须记录三个基本属性 (1)信息将存储在哪 (2)要存储 ...

  4. 20170722_php_单例模式

    <?php class myClass{ private static $obj = null; private function __construc(){ } public static f ...

  5. nyoj_253:LK的旅行(旋转卡壳入门)

    题目链接 求平面最大点对. 找凸包 -> 根据凸包运用旋转卡壳算法求最大点对(套用kuang巨模板) 关于旋转卡壳算法 #include<bits/stdc++.h> using n ...

  6. PL/SQL入门随笔

    PL/SQL(Procedure Language/SQL) PLSQL是Oracle对sql语言的过程化扩展:在SQL命令语言中增加了过程处理语句(如分支.循环等),使SQL语言具有过程处理能力.S ...

  7. SpringMVC源码情操陶冶-View视图渲染

    本节简单分析View视图对象的render方法 View接口 最重要的就是render()方法,具体源码如下 /** * Render the view given the specified mod ...

  8. (转)log4j(七)——log4j.xml简单配置样例说明

    背景:在公司中警察需要做技术支持,查看日志,而查看日志首先要自己清楚日志是如何生成的,所以有必要知道日志的前世今生! 转载出处:http://www.cnblogs.com/godtrue/p/644 ...

  9. python3之微信文章爬虫

    前提: python3.4 windows 作用:通过搜狗的微信搜索接口http://weixin.sogou.com/来搜索相关微信文章,并将标题及相关链接导入Excel表格中 说明:需xlsxwr ...

  10. 【Django】Django与jinja的不同

    1. http://jinja.pocoo.org/docs/dev/switching/#django 目前已了解的不同: 1) 某元素是否存在 if xxx   Django if xxx is ...