chore(remote43): standardize stable crm repo root
This commit is contained in:
@@ -72,14 +72,17 @@ render_remote43_crm_env() {
|
||||
local crm_port="$1"
|
||||
local sqlite_dsn="$2"
|
||||
local admin_token="$3"
|
||||
local sqlite_dsn_q admin_token_q
|
||||
local repo_root="${4:-}"
|
||||
local sqlite_dsn_q admin_token_q repo_root_q
|
||||
printf -v sqlite_dsn_q '%q' "$sqlite_dsn"
|
||||
printf -v admin_token_q '%q' "$admin_token"
|
||||
printf -v repo_root_q '%q' "$repo_root"
|
||||
|
||||
cat <<EOF
|
||||
SUB2API_CRM_LISTEN_ADDR=127.0.0.1:$crm_port
|
||||
SUB2API_CRM_SQLITE_DSN=$sqlite_dsn_q
|
||||
SUB2API_CRM_ADMIN_TOKEN=$admin_token_q
|
||||
SUB2API_CRM_REPO_ROOT=$repo_root_q
|
||||
SUB2API_CRM_RECONCILE_WORKER_ENABLED=false
|
||||
EOF
|
||||
}
|
||||
@@ -106,11 +109,13 @@ render_remote43_bootstrap_script() {
|
||||
local host_port="${19}"
|
||||
local crm_port="${20}"
|
||||
local host_container_port="${21}"
|
||||
local remote_repo_root="${22}"
|
||||
local remote_repo_bundle="${23}"
|
||||
|
||||
local remote_root_q host_env_q crm_env_q host_binary_q crm_binary_q
|
||||
local data_dir_q crm_db_q crm_pid_q crm_log_q app_q pg_q redis_q
|
||||
local network_q host_image_q pg_image_q redis_image_q db_password_q db_name_q
|
||||
local host_port_q crm_port_q host_container_port_q
|
||||
local host_port_q crm_port_q host_container_port_q remote_repo_root_q remote_repo_bundle_q
|
||||
remote_root_q="$(printf '%q' "$remote_root")"
|
||||
host_env_q="$(printf '%q' "$host_env_file")"
|
||||
crm_env_q="$(printf '%q' "$crm_env_file")"
|
||||
@@ -132,6 +137,8 @@ render_remote43_bootstrap_script() {
|
||||
host_port_q="$(printf '%q' "$host_port")"
|
||||
crm_port_q="$(printf '%q' "$crm_port")"
|
||||
host_container_port_q="$(printf '%q' "$host_container_port")"
|
||||
remote_repo_root_q="$(printf '%q' "$remote_repo_root")"
|
||||
remote_repo_bundle_q="$(printf '%q' "$remote_repo_bundle")"
|
||||
|
||||
cat <<EOF
|
||||
#!/usr/bin/env bash
|
||||
@@ -158,8 +165,10 @@ DB_NAME=$db_name_q
|
||||
HOST_PORT=$host_port_q
|
||||
CRM_PORT=$crm_port_q
|
||||
HOST_CONTAINER_PORT=$host_container_port_q
|
||||
REMOTE_REPO_ROOT=$remote_repo_root_q
|
||||
REMOTE_REPO_BUNDLE=$remote_repo_bundle_q
|
||||
|
||||
mkdir -p "\$REMOTE_ROOT" "\$DATA_DIR"
|
||||
mkdir -p "\$REMOTE_ROOT" "\$DATA_DIR" "\$(dirname "\$REMOTE_REPO_ROOT")"
|
||||
chmod 755 "\$HOST_BINARY" "\$CRM_BINARY"
|
||||
|
||||
rm -f "\$DATA_DIR/install.lock" "\$DATA_DIR/config.yaml" "\$DATA_DIR/.installed"
|
||||
@@ -189,9 +198,22 @@ sudo -n docker run -d --name "\$APP_CONTAINER" --network "\$NETWORK_NAME" \\
|
||||
-p "127.0.0.1:\$HOST_PORT:\$HOST_CONTAINER_PORT" \\
|
||||
--env-file "\$HOST_ENV_FILE" \\
|
||||
-v "\$DATA_DIR:/app/data" \\
|
||||
-v "\$HOST_BINARY:/app/sub2api:ro" \\
|
||||
-v "\$HOST_BINARY:/app/sub2api:ro" \\
|
||||
"\$HOST_IMAGE" /app/sub2api >/dev/null
|
||||
|
||||
if [[ -f "\$REMOTE_REPO_BUNDLE" ]]; then
|
||||
if [[ -d "\$REMOTE_REPO_ROOT/.git" ]]; then
|
||||
git -C "\$REMOTE_REPO_ROOT" fetch "\$REMOTE_REPO_BUNDLE" main
|
||||
git -C "\$REMOTE_REPO_ROOT" reset --hard FETCH_HEAD
|
||||
else
|
||||
rm -rf "\$REMOTE_REPO_ROOT"
|
||||
git clone "\$REMOTE_REPO_BUNDLE" "\$REMOTE_REPO_ROOT"
|
||||
git -C "\$REMOTE_REPO_ROOT" checkout main
|
||||
fi
|
||||
git -C "\$REMOTE_REPO_ROOT" config user.name "Remote43 CRM"
|
||||
git -C "\$REMOTE_REPO_ROOT" config user.email "remote43-crm@tksea.top"
|
||||
fi
|
||||
|
||||
python3 - "\$HOST_ENV_FILE" "\$HOST_PORT" <<'PY'
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
Reference in New Issue
Block a user