first
This commit is contained in:
48
domain-api/deploy/multi-region/bootstrap_overseas.sh
Executable file
48
domain-api/deploy/multi-region/bootstrap_overseas.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BASE_DIR="${1:-/opt/domaincheck}"
|
||||
API_DIR="$BASE_DIR/domain-api"
|
||||
WEB_DIR="$BASE_DIR/domain-web"
|
||||
RUNTIME_DIR="$API_DIR/runtime"
|
||||
SERVICE_NAME="domaincheck-api"
|
||||
ENV_FILE="/etc/default/domaincheck-api"
|
||||
TEMPLATE_FILE="$API_DIR/deploy/multi-region/templates/domaincheck-api.env.example"
|
||||
|
||||
echo "[1/6] preparing directories"
|
||||
mkdir -p "$BASE_DIR" "$API_DIR" "$WEB_DIR" "$RUNTIME_DIR"
|
||||
|
||||
echo "[2/6] checking python environment"
|
||||
if [ ! -x "$BASE_DIR/domainCheck/.venv/bin/python" ]; then
|
||||
echo "missing python venv: $BASE_DIR/domainCheck/.venv/bin/python"
|
||||
echo "please deploy domainCheck first and create .venv there"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[3/6] installing api dependencies"
|
||||
"$BASE_DIR/domainCheck/.venv/bin/pip" install -q fastapi uvicorn pydantic-settings psycopg2-binary redis openpyxl python-multipart
|
||||
|
||||
echo "[4/6] installing systemd service"
|
||||
install -m 0644 "$API_DIR/deploy/systemd/domain-api.service" "/etc/systemd/system/${SERVICE_NAME}.service"
|
||||
|
||||
echo "[4.5/6] preparing environment file"
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
install -m 0644 "$TEMPLATE_FILE" "$ENV_FILE"
|
||||
sed -i "s#__BASE_DIR__#${BASE_DIR}#g" "$ENV_FILE"
|
||||
chmod 0644 "$ENV_FILE"
|
||||
echo "created env template: $ENV_FILE"
|
||||
else
|
||||
echo "env file already exists: $ENV_FILE"
|
||||
fi
|
||||
|
||||
echo "[5/6] reloading systemd"
|
||||
systemctl daemon-reload
|
||||
|
||||
echo "[6/6] summary"
|
||||
echo "overseas bootstrap completed"
|
||||
echo "service: ${SERVICE_NAME}"
|
||||
echo "next commands:"
|
||||
echo " systemctl enable ${SERVICE_NAME}"
|
||||
echo " systemctl restart ${SERVICE_NAME}"
|
||||
echo " systemctl status ${SERVICE_NAME} --no-pager -l"
|
||||
echo " vi ${ENV_FILE}"
|
||||
Reference in New Issue
Block a user