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