Add bygsf212 deployment config
This commit is contained in:
39
deploy/docker/scripts/bootstrap-remote-env.sh
Executable file
39
deploy/docker/scripts/bootstrap-remote-env.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# =============================================================
|
||||
# 首次部署:在远端创建 .env 模板(仅在缺失时创建)
|
||||
# 同步代码后执行: ./bootstrap-remote-env.sh
|
||||
# 之后 ssh 上去 vim 这两个文件填入真实密码即可
|
||||
# =============================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
if [ -f "$SCRIPT_DIR/server.env" ]; then
|
||||
set -a; . "$SCRIPT_DIR/server.env"; set +a
|
||||
fi
|
||||
|
||||
SERVER_HOST="${SERVER_HOST:?}"
|
||||
SERVER_USER="${SERVER_USER:-root}"
|
||||
SERVER_PORT="${SERVER_PORT:-22}"
|
||||
REMOTE_DIR="${REMOTE_DIR:-/root/integral-shop}"
|
||||
|
||||
if [ -n "${SSHPASS:-}" ]; then
|
||||
command -v sshpass >/dev/null || { echo "需要 sshpass"; exit 1; }
|
||||
export SSHPASS
|
||||
SSH=(sshpass -e ssh -p "$SERVER_PORT" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null)
|
||||
else
|
||||
SSH=(ssh -p "$SERVER_PORT" -o StrictHostKeyChecking=no)
|
||||
fi
|
||||
|
||||
"${SSH[@]}" "${SERVER_USER}@${SERVER_HOST}" bash -se <<EOSSH
|
||||
set -e
|
||||
cd "${REMOTE_DIR}/deploy/docker"
|
||||
[ -f .env ] || { cp .env.example .env; echo "[+] 已创建 .env (基于 .env.example)"; }
|
||||
[ -f integral-resell/.env ] || { cp integral-resell/.env.template integral-resell/.env; echo "[+] 已创建 integral-resell/.env"; }
|
||||
|
||||
echo
|
||||
echo "请在远端编辑以下文件填入真实参数:"
|
||||
echo " ${REMOTE_DIR}/deploy/docker/.env"
|
||||
echo " ${REMOTE_DIR}/deploy/docker/integral-resell/.env"
|
||||
EOSSH
|
||||
Reference in New Issue
Block a user