• 自动化更新包文件--shell脚本


    背景

    作为一名实施工程师,当然也协助做些测试的工作,当产品功能开发后,研发会将本次迭代涉及的前后端包文件提供过来。有时会因为一些原因研发没法现场开发,那就需要我们配合测试并将情况反馈给研发,会频繁的更新包文件。手动更包除了麻烦效率也低,所以建议自动化脚本更包,其实也就是把手动命令写到一个shell脚本中直接执行。
    有些客户环境有自动化运维应用,直接把脚本内容复制粘贴运行即可,同理。

    手动更包

    前端包operation
    涉及到前端定制化页面展示,除了必要js文件保留不变,其他均采用本次operation包。
    后端包diagram.jar
    更新整个diagram.jar包,或者在原jar包基础上更新部分class文件。
    连接服务器
    从某服务器获取更新包,或把文件包传到某服务器以便更包。

    手动更包代码片.

    // 备份原包放到bak下
    mkdir -p /2024/20240328/bak
    mv /test/webapp/operation /2024/20240328/bak
    // 部署新包放到指定文件夹下
    cd /2024/20240328
    sftp -o port=1234 engineer@1.2.3.4
    // 此处需要输入密码Engineer@123
    cd /test/engineer
    get operation.zip
    exit
    // 然后对新包处理
    unzip operation.zip 
    mv operation /test/webapp/operation
    // 替换部分文件
    cp /2024/20240328/bak/operation/static/domain.js   /test/webapp/operation/static/
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    自动化更包

    touch update.sh
    vi update.sh

    更包代码片.

    #!/usr/bin/sh
    // 备份原包放到bak下
    mkdir -p /2024/20240328/bak
    mv /test/webapp/operation /2024/20240328/bak
    // 部署新包放到指定文件夹下
    cd /2024/20240328
    curl -u engineer:Engineer'@'123 -O "sftp://1.2.3.4:1234/test/engineer/operation.zip"
    unzip operation.zip 
    mv operation /test/webapp/operation
    // 替换部分文件
    cp /2024/20240328/bak/operation/static/domain.js   /test/webapp/operation/static/
    update_time=$(date "+%Y-%m-%d %H:%M:%S")#
    current_date=$(date "+%Y-%m-%d")#
    current_time=$(date "+%H:%M:%S")#
    echo "更新时间:$update_time"#
    echo "当前日期:$current_date"#
    echo "当前时间:$current_time"#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    ====
    sh update.sh
    完成

  • 相关阅读:
    Spring MVC LocaleResolver原理解析
    RecyclerView高效使用第二节
    Go Sync并发包之errgroup
    2022年0701-Com.Java.Basis第五课《针对流程控制的语句练习题》
    2024清理mac苹果电脑内存免费工具CleanMyMac X4.15
    数据仓库(5)数仓Kimball与Inmon架构的对比
    Spring 统一处理(JavaEE进阶系列6)
    52、Flink 使用 Parametertool 获取应用参数代码示例
    FPGA实现Avalon-MM接口通信
    算法----滑动窗口
  • 原文地址:https://blog.csdn.net/m0_64295612/article/details/137079856