update-client.sh 脚本已经过修改,现在支持在 Windows (Git Bash) 环境中运行。该脚本用于从版本服务器下载并更新 H5 应用。
脚本会自动检测运行环境:
%TEMP% 或 %TMP% 环境变量/tmp%USERNAME% 环境变量$USER 环境变量锁文件会根据操作系统自动选择合适的临时目录,避免路径问题。
curlwgettargrepsort./update-client.sh
脚本会提示您输入:
# 不包含 static 文件夹
./update-client.sh -u deploy -p mypassword -d ./h5 -v latest -y
# 包含 static 文件夹
./update-client.sh -u deploy -p mypassword -d ./h5 -v latest -y --include-static
# 指定特定版本
./update-client.sh -u deploy -p mypassword -v v1.1.5-20251129-062104 -y
./update-client.sh -u deploy -p mypassword -v latest -y -s
| 选项 | 说明 |
|---|---|
-u, --user USERNAME |
指定用户名(默认: deploy) |
-p, --password PASS |
指定密码 |
-d, --dir DIRECTORY |
指定下载目录(默认: ./h5) |
-v, --version VERSION |
指定版本号(默认: latest) |
-i, --include-static |
包含 static 文件夹更新 |
-y, --yes |
跳过确认提示 |
-s, --silent |
静默模式(最小输出) |
-h, --help |
显示帮助信息 |
./logs 目录创建日志文件日志文件保存在 ./logs 目录,文件名格式:
update_YYYYMMDD_HHMMSS.log
如果遇到权限错误,在 Git Bash 中运行:
chmod +x update-client.sh
如果 %TEMP% 不可用,脚本会回退到 /tmp
如果脚本异常退出,可能留下锁文件:
# 手动删除锁文件
rm -f $TEMP/update-client-$USERNAME.lock
确认 Git Bash 包含所需工具:
which curl wget tar
detect_os() 函数: 自动检测操作系统类型show_os_info() 函数: 显示运行环境信息%USERNAME% 变量[INFO] 日志文件: ./logs/update_20251218_103000.log
[INFO] 检测到操作系统: windows
[INFO] 临时目录: C:\Users\YourName\AppData\Local\Temp
[INFO] 当前用户: YourName
[INFO] 检查依赖工具...
[✓] 依赖工具检查通过
[INFO] 已创建锁文件
[INFO] 用户名: deploy
...
static 文件夹,需要时使用 -i 参数✅ Windows 10/11 (Git Bash)
✅ Linux (所有发行版)
✅ macOS
✅ WSL (Windows Subsystem for Linux)
✅ Cygwin
✅ MSYS2