新增本机保存发布密码的小工具

- scripts/store-deploy-password.sh:交互输入一次服务器密码,写入 runtime/private/deploy-password
  (权限 600、已被 Git 忽略),避免依赖系统钥匙串授权窗口
- deploy-from-mac.sh 在该文件存在时自动使用,无需额外参数
This commit is contained in:
renshen 2026-09-30 11:37:34 +08:00
parent ff3f3424c5
commit a8f3178ab1
2 changed files with 38 additions and 0 deletions

View File

@ -74,6 +74,12 @@ done
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd "$script_dir/.." && pwd)"
# 本机私有密码文件(scripts/store-deploy-password.sh 保存的),存在就自动使用。
if [ -z "$password_file" ] && [ -f "$repo_root/runtime/private/deploy-password" ]; then
password_file="$repo_root/runtime/private/deploy-password"
fi
image_name='caiwu_akaunting'
target_platform='linux/amd64'
image_prefix='127.0.0.1:5000/caiwuxitong/app'

View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
#
# 在本机保存发布用的服务器密码:只写入 runtime/private/deploy-password(权限 600),
# 该目录已被 Git 忽略,不会提交、不会进日志。之后 scripts/deploy-from-mac.sh 会自动使用它。
#
# 用法:bash scripts/store-deploy-password.sh [root@服务器地址]
#
set -euo pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd "$script_dir/.." && pwd)"
server="${1:-root@218.93.190.75}"
target="$repo_root/runtime/private/deploy-password"
mkdir -p "$repo_root/runtime/private"
umask 077
printf '服务器密码(%s,输入时不显示):' "$server" >&2
read -rs password
printf '\n' >&2
if [ -z "$password" ]; then
echo '没有输入内容,已取消。' >&2
exit 1
fi
printf '%s' "$password" > "$target"
chmod 600 "$target"
unset password
echo "已保存到 $target"
echo '该文件只在本机、已排除 Git;要更换密码重新运行本脚本即可。'