当前位置:   article > 正文

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

自动化更新包文件--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
完成

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/368355
推荐阅读
  

闽ICP备14008679号