mirror of
https://github.com/uprightbass360/AzerothCore-RealmMaster.git
synced 2026-01-31 01:13:49 +00:00
deploy updates
This commit is contained in:
55
deploy.sh
55
deploy.sh
@@ -35,6 +35,9 @@ REMOTE_COPY_SOURCE=0
|
|||||||
REMOTE_ARGS_PROVIDED=0
|
REMOTE_ARGS_PROVIDED=0
|
||||||
REMOTE_AUTO_DEPLOY=0
|
REMOTE_AUTO_DEPLOY=0
|
||||||
REMOTE_AUTO_DEPLOY=0
|
REMOTE_AUTO_DEPLOY=0
|
||||||
|
REMOTE_STORAGE_OVERRIDE=""
|
||||||
|
REMOTE_CONTAINER_USER_OVERRIDE=""
|
||||||
|
REMOTE_ENV_FILE=""
|
||||||
|
|
||||||
MODULE_HELPER="$ROOT_DIR/scripts/python/modules.py"
|
MODULE_HELPER="$ROOT_DIR/scripts/python/modules.py"
|
||||||
MODULE_STATE_INITIALIZED=0
|
MODULE_STATE_INITIALIZED=0
|
||||||
@@ -164,6 +167,23 @@ collect_remote_details(){
|
|||||||
*) REMOTE_SKIP_STORAGE=0 ;;
|
*) REMOTE_SKIP_STORAGE=0 ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Optional remote env overrides (default to current values)
|
||||||
|
local storage_default container_user_default
|
||||||
|
storage_default="$(read_env STORAGE_PATH "./storage")"
|
||||||
|
container_user_default="$(read_env CONTAINER_USER "$(id -u):$(id -g)")"
|
||||||
|
|
||||||
|
if [ -z "$REMOTE_STORAGE_OVERRIDE" ] && [ "$interactive" -eq 1 ]; then
|
||||||
|
local storage_input
|
||||||
|
read -rp "Remote storage path (STORAGE_PATH) [${storage_default}]: " storage_input
|
||||||
|
REMOTE_STORAGE_OVERRIDE="${storage_input:-$storage_default}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$REMOTE_CONTAINER_USER_OVERRIDE" ] && [ "$interactive" -eq 1 ]; then
|
||||||
|
local cu_input
|
||||||
|
read -rp "Remote container user (CONTAINER_USER) [${container_user_default}]: " cu_input
|
||||||
|
REMOTE_CONTAINER_USER_OVERRIDE="${cu_input:-$container_user_default}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_remote_configuration(){
|
validate_remote_configuration(){
|
||||||
@@ -220,6 +240,8 @@ Options:
|
|||||||
--remote-skip-storage Skip syncing the storage directory during migration
|
--remote-skip-storage Skip syncing the storage directory during migration
|
||||||
--remote-copy-source Copy the local project directory to remote instead of relying on git
|
--remote-copy-source Copy the local project directory to remote instead of relying on git
|
||||||
--remote-auto-deploy Run './deploy.sh --yes --no-watch' on the remote host after migration
|
--remote-auto-deploy Run './deploy.sh --yes --no-watch' on the remote host after migration
|
||||||
|
--remote-storage-path PATH Override STORAGE_PATH/STORAGE_PATH_LOCAL in the remote .env
|
||||||
|
--remote-container-user USER[:GROUP] Override CONTAINER_USER in the remote .env
|
||||||
--skip-config Skip applying server configuration preset
|
--skip-config Skip applying server configuration preset
|
||||||
-h, --help Show this help
|
-h, --help Show this help
|
||||||
|
|
||||||
@@ -248,6 +270,8 @@ while [[ $# -gt 0 ]]; do
|
|||||||
--remote-skip-storage) REMOTE_SKIP_STORAGE=1; REMOTE_MODE=1; REMOTE_ARGS_PROVIDED=1; shift;;
|
--remote-skip-storage) REMOTE_SKIP_STORAGE=1; REMOTE_MODE=1; REMOTE_ARGS_PROVIDED=1; shift;;
|
||||||
--remote-copy-source) REMOTE_COPY_SOURCE=1; REMOTE_MODE=1; REMOTE_ARGS_PROVIDED=1; shift;;
|
--remote-copy-source) REMOTE_COPY_SOURCE=1; REMOTE_MODE=1; REMOTE_ARGS_PROVIDED=1; shift;;
|
||||||
--remote-auto-deploy) REMOTE_AUTO_DEPLOY=1; REMOTE_MODE=1; REMOTE_ARGS_PROVIDED=1; shift;;
|
--remote-auto-deploy) REMOTE_AUTO_DEPLOY=1; REMOTE_MODE=1; REMOTE_ARGS_PROVIDED=1; shift;;
|
||||||
|
--remote-storage-path) REMOTE_STORAGE_OVERRIDE="$2"; REMOTE_MODE=1; REMOTE_ARGS_PROVIDED=1; shift 2;;
|
||||||
|
--remote-container-user) REMOTE_CONTAINER_USER_OVERRIDE="$2"; REMOTE_MODE=1; REMOTE_ARGS_PROVIDED=1; shift 2;;
|
||||||
--skip-config) SKIP_CONFIG=1; shift;;
|
--skip-config) SKIP_CONFIG=1; shift;;
|
||||||
-h|--help) usage; exit 0;;
|
-h|--help) usage; exit 0;;
|
||||||
*) err "Unknown option: $1"; usage; exit 1;;
|
*) err "Unknown option: $1"; usage; exit 1;;
|
||||||
@@ -607,6 +631,33 @@ determine_profile(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_remote_migration(){
|
run_remote_migration(){
|
||||||
|
if [ -z "$REMOTE_ENV_FILE" ] && { [ -n "$REMOTE_STORAGE_OVERRIDE" ] || [ -n "$REMOTE_CONTAINER_USER_OVERRIDE" ]; }; then
|
||||||
|
local base_env=""
|
||||||
|
if [ -f "$ENV_PATH" ]; then
|
||||||
|
base_env="$ENV_PATH"
|
||||||
|
elif [ -f "$TEMPLATE_PATH" ]; then
|
||||||
|
base_env="$TEMPLATE_PATH"
|
||||||
|
fi
|
||||||
|
REMOTE_ENV_FILE="$(mktemp)"
|
||||||
|
if [ -n "$base_env" ]; then
|
||||||
|
cp "$base_env" "$REMOTE_ENV_FILE"
|
||||||
|
else
|
||||||
|
: > "$REMOTE_ENV_FILE"
|
||||||
|
fi
|
||||||
|
if [ -n "$REMOTE_STORAGE_OVERRIDE" ]; then
|
||||||
|
{
|
||||||
|
echo
|
||||||
|
echo "STORAGE_PATH=$REMOTE_STORAGE_OVERRIDE"
|
||||||
|
} >>"$REMOTE_ENV_FILE"
|
||||||
|
fi
|
||||||
|
if [ -n "$REMOTE_CONTAINER_USER_OVERRIDE" ]; then
|
||||||
|
{
|
||||||
|
echo
|
||||||
|
echo "CONTAINER_USER=$REMOTE_CONTAINER_USER_OVERRIDE"
|
||||||
|
} >>"$REMOTE_ENV_FILE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
local args=(--host "$REMOTE_HOST" --user "$REMOTE_USER")
|
local args=(--host "$REMOTE_HOST" --user "$REMOTE_USER")
|
||||||
|
|
||||||
if [ -n "$REMOTE_PORT" ] && [ "$REMOTE_PORT" != "22" ]; then
|
if [ -n "$REMOTE_PORT" ] && [ "$REMOTE_PORT" != "22" ]; then
|
||||||
@@ -633,6 +684,10 @@ run_remote_migration(){
|
|||||||
args+=(--yes)
|
args+=(--yes)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$REMOTE_ENV_FILE" ]; then
|
||||||
|
args+=(--env-file "$REMOTE_ENV_FILE")
|
||||||
|
fi
|
||||||
|
|
||||||
(cd "$ROOT_DIR" && ./scripts/bash/migrate-stack.sh "${args[@]}")
|
(cd "$ROOT_DIR" && ./scripts/bash/migrate-stack.sh "${args[@]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,6 +170,8 @@ Optional flags:
|
|||||||
- `--remote-port 2222` - Custom SSH port
|
- `--remote-port 2222` - Custom SSH port
|
||||||
- `--remote-identity ~/.ssh/custom_key` - Specific SSH key
|
- `--remote-identity ~/.ssh/custom_key` - Specific SSH key
|
||||||
- `--remote-skip-storage` - Don't sync storage directory (fresh install on remote)
|
- `--remote-skip-storage` - Don't sync storage directory (fresh install on remote)
|
||||||
|
- `--remote-storage-path /mnt/acore-storage` - Override STORAGE_PATH on the remote host (local-storage stays per .env)
|
||||||
|
- `--remote-container-user 1001:1001` - Override CONTAINER_USER on the remote host (uid:gid)
|
||||||
|
|
||||||
### Step 3: Deploy on Remote Host
|
### Step 3: Deploy on Remote Host
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ Options:
|
|||||||
--port PORT SSH port (default: 22)
|
--port PORT SSH port (default: 22)
|
||||||
--identity PATH SSH private key (passed to scp/ssh)
|
--identity PATH SSH private key (passed to scp/ssh)
|
||||||
--project-dir DIR Remote project directory (default: ~/<project-name>)
|
--project-dir DIR Remote project directory (default: ~/<project-name>)
|
||||||
|
--env-file PATH Use this env file for image lookup and upload (default: ./.env)
|
||||||
--tarball PATH Output path for the image tar (default: ./local-storage/images/acore-modules-images.tar)
|
--tarball PATH Output path for the image tar (default: ./local-storage/images/acore-modules-images.tar)
|
||||||
--storage PATH Remote storage directory (default: <project-dir>/storage)
|
--storage PATH Remote storage directory (default: <project-dir>/storage)
|
||||||
--skip-storage Do not sync the storage directory
|
--skip-storage Do not sync the storage directory
|
||||||
@@ -171,6 +172,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
--port) PORT="$2"; shift 2;;
|
--port) PORT="$2"; shift 2;;
|
||||||
--identity) IDENTITY="$2"; shift 2;;
|
--identity) IDENTITY="$2"; shift 2;;
|
||||||
--project-dir) PROJECT_DIR="$2"; shift 2;;
|
--project-dir) PROJECT_DIR="$2"; shift 2;;
|
||||||
|
--env-file) ENV_FILE="$2"; shift 2;;
|
||||||
--tarball) TARBALL="$2"; shift 2;;
|
--tarball) TARBALL="$2"; shift 2;;
|
||||||
--storage) REMOTE_STORAGE="$2"; shift 2;;
|
--storage) REMOTE_STORAGE="$2"; shift 2;;
|
||||||
--skip-storage) SKIP_STORAGE=1; shift;;
|
--skip-storage) SKIP_STORAGE=1; shift;;
|
||||||
@@ -187,6 +189,14 @@ if [[ -z "$HOST" || -z "$USER" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Normalize env file path if provided and recompute defaults
|
||||||
|
if [ -n "$ENV_FILE" ] && [ -f "$ENV_FILE" ]; then
|
||||||
|
ENV_FILE="$(cd "$(dirname "$ENV_FILE")" && pwd)/$(basename "$ENV_FILE")"
|
||||||
|
else
|
||||||
|
ENV_FILE="$PROJECT_ROOT/.env"
|
||||||
|
fi
|
||||||
|
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_FILE" "$TEMPLATE_FILE")"
|
||||||
|
|
||||||
expand_remote_path(){
|
expand_remote_path(){
|
||||||
local path="$1"
|
local path="$1"
|
||||||
case "$path" in
|
case "$path" in
|
||||||
@@ -224,7 +234,11 @@ resolve_path_relative_to_project(){
|
|||||||
echo "${path%/}"
|
echo "${path%/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
STAGE_SQL_PATH_RAW="$(read_env_value STAGE_PATH_MODULE_SQL "${STORAGE_PATH_LOCAL:-./local-storage}/module-sql-updates")"
|
STAGE_SQL_PATH_RAW="$(read_env_value STAGE_PATH_MODULE_SQL "${LOCAL_STORAGE_ROOT:-./local-storage}/module-sql-updates")"
|
||||||
|
# Ensure STORAGE_PATH_LOCAL is defined to avoid set -u failures during expansion
|
||||||
|
if [ -z "${STORAGE_PATH_LOCAL:-}" ]; then
|
||||||
|
STORAGE_PATH_LOCAL="$LOCAL_STORAGE_ROOT"
|
||||||
|
fi
|
||||||
# Expand any env references (e.g., ${STORAGE_PATH_LOCAL})
|
# Expand any env references (e.g., ${STORAGE_PATH_LOCAL})
|
||||||
STAGE_SQL_PATH_RAW="$(eval "echo \"$STAGE_SQL_PATH_RAW\"")"
|
STAGE_SQL_PATH_RAW="$(eval "echo \"$STAGE_SQL_PATH_RAW\"")"
|
||||||
LOCAL_STAGE_SQL_DIR="$(resolve_path_relative_to_project "$STAGE_SQL_PATH_RAW" "$PROJECT_ROOT")"
|
LOCAL_STAGE_SQL_DIR="$(resolve_path_relative_to_project "$STAGE_SQL_PATH_RAW" "$PROJECT_ROOT")"
|
||||||
@@ -396,6 +410,9 @@ validate_remote_environment
|
|||||||
collect_deploy_image_refs
|
collect_deploy_image_refs
|
||||||
|
|
||||||
echo "⋅ Exporting deployment images to $TARBALL"
|
echo "⋅ Exporting deployment images to $TARBALL"
|
||||||
|
# Ensure destination directory exists
|
||||||
|
ensure_host_writable "$(dirname "$TARBALL")"
|
||||||
|
|
||||||
# Check which images are available and collect them
|
# Check which images are available and collect them
|
||||||
IMAGES_TO_SAVE=()
|
IMAGES_TO_SAVE=()
|
||||||
MISSING_IMAGES=()
|
MISSING_IMAGES=()
|
||||||
@@ -487,9 +504,9 @@ ensure_remote_temp_dir
|
|||||||
run_scp "$TARBALL" "$USER@$HOST:$REMOTE_TEMP_DIR/acore-modules-images.tar"
|
run_scp "$TARBALL" "$USER@$HOST:$REMOTE_TEMP_DIR/acore-modules-images.tar"
|
||||||
run_ssh "docker load < '$REMOTE_TEMP_DIR/acore-modules-images.tar' && rm '$REMOTE_TEMP_DIR/acore-modules-images.tar'"
|
run_ssh "docker load < '$REMOTE_TEMP_DIR/acore-modules-images.tar' && rm '$REMOTE_TEMP_DIR/acore-modules-images.tar'"
|
||||||
|
|
||||||
if [[ -f .env ]]; then
|
if [[ -f "$ENV_FILE" ]]; then
|
||||||
echo "⋅ Uploading .env"
|
echo "⋅ Uploading .env"
|
||||||
run_scp .env "$USER@$HOST:$PROJECT_DIR/.env"
|
run_scp "$ENV_FILE" "$USER@$HOST:$PROJECT_DIR/.env"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "⋅ Remote prepares completed"
|
echo "⋅ Remote prepares completed"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module acore-compose/statusdash
|
module acore-compose/statusdash
|
||||||
|
|
||||||
go 1.22.2
|
go 1.22
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gizak/termui/v3 v3.1.0 // indirect
|
github.com/gizak/termui/v3 v3.1.0 // indirect
|
||||||
|
|||||||
Reference in New Issue
Block a user