- scripts/store-deploy-password.sh:交互输入一次服务器密码,写入 runtime/private/deploy-password (权限 600、已被 Git 忽略),避免依赖系统钥匙串授权窗口 - deploy-from-mac.sh 在该文件存在时自动使用,无需额外参数
33 lines
973 B
Bash
Executable File
33 lines
973 B
Bash
Executable File
#!/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;要更换密码重新运行本脚本即可。'
|