mirror of
https://github.com/uprightbass360/AzerothCore-RealmMaster.git
synced 2026-01-13 09:07:20 +00:00
tagging updates
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Utility to migrate the current acore-compose stack to a remote host.
|
||||
# It assumes the module images have already been rebuilt locally.
|
||||
# Utility to migrate module images (and optionally storage) to a remote host.
|
||||
# Assumes module images have already been rebuilt locally.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage(){
|
||||
cat <<EOF
|
||||
cat <<'EOF_HELP'
|
||||
Usage: $(basename "$0") --host HOST --user USER [options]
|
||||
|
||||
Options:
|
||||
@@ -14,16 +14,12 @@ Options:
|
||||
--user USER SSH username on remote host (required)
|
||||
--port PORT SSH port (default: 22)
|
||||
--identity PATH SSH private key (passed to scp/ssh)
|
||||
--project-dir DIR Remote directory for the project (default: ~/acore-compose)
|
||||
--tarball PATH Output path for the image tar (default: ./acore-modules-images.tar)
|
||||
--project-dir DIR Remote project directory (default: ~/acore-compose)
|
||||
--tarball PATH Output path for the image tar (default: ./images/acore-modules-images.tar)
|
||||
--storage PATH Remote storage directory (default: <project-dir>/storage)
|
||||
--skip-images Do not export/import Docker images
|
||||
--skip-storage Do not sync the storage directory
|
||||
--help Show this help
|
||||
|
||||
Example:
|
||||
$(basename "$0") --host wow.example.com --user deploy --identity ~/.ssh/id_ed25519 \
|
||||
--project-dir /opt/acore-compose
|
||||
EOF
|
||||
EOF_HELP
|
||||
}
|
||||
|
||||
HOST=""
|
||||
@@ -33,7 +29,7 @@ IDENTITY=""
|
||||
PROJECT_DIR=""
|
||||
TARBALL=""
|
||||
REMOTE_STORAGE=""
|
||||
SKIP_IMAGES=0
|
||||
SKIP_STORAGE=0
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
@@ -44,11 +40,11 @@ while [[ $# -gt 0 ]]; do
|
||||
--project-dir) PROJECT_DIR="$2"; shift 2;;
|
||||
--tarball) TARBALL="$2"; shift 2;;
|
||||
--storage) REMOTE_STORAGE="$2"; shift 2;;
|
||||
--skip-images) SKIP_IMAGES=1; shift;;
|
||||
--skip-storage) SKIP_STORAGE=1; shift;;
|
||||
--help|-h) usage; exit 0;;
|
||||
*) echo "Unknown option: $1" >&2; usage; exit 1;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
|
||||
if [[ -z "$HOST" || -z "$USER" ]]; then
|
||||
echo "--host and --user are required" >&2
|
||||
@@ -58,7 +54,7 @@ fi
|
||||
|
||||
PROJECT_DIR="${PROJECT_DIR:-/home/${USER}/acore-compose}"
|
||||
REMOTE_STORAGE="${REMOTE_STORAGE:-${PROJECT_DIR}/storage}"
|
||||
TARBALL="${TARBALL:-$(pwd)/acore-modules-images.tar}"
|
||||
TARBALL="${TARBALL:-$(pwd)/images/acore-modules-images.tar}"
|
||||
|
||||
SCP_OPTS=(-P "$PORT")
|
||||
SSH_OPTS=(-p "$PORT")
|
||||
@@ -75,40 +71,36 @@ run_scp(){
|
||||
scp "${SCP_OPTS[@]}" "$@"
|
||||
}
|
||||
|
||||
echo "⋅ Preparing project archive"
|
||||
TMP_PROJECT_ARCHIVE="$(mktemp -u acore-compose-XXXXXX.tar.gz)"
|
||||
tar --exclude '.git' --exclude 'storage/backups' --exclude 'storage/logs' \
|
||||
--exclude 'acore-modules-images.tar' -czf "$TMP_PROJECT_ARCHIVE" -C "$(pwd)/.." "$(basename "$(pwd)")"
|
||||
echo "⋅ Exporting module images to $TARBALL"
|
||||
mkdir -p "$(dirname "$TARBALL")"
|
||||
IMAGES_TO_SAVE=(
|
||||
acore/ac-wotlk-worldserver:modules-latest
|
||||
acore/ac-wotlk-authserver:modules-latest
|
||||
)
|
||||
if docker image inspect uprightbass360/azerothcore-wotlk-playerbots:worldserver-Playerbot >/dev/null 2>&1; then
|
||||
IMAGES_TO_SAVE+=(uprightbass360/azerothcore-wotlk-playerbots:worldserver-Playerbot)
|
||||
fi
|
||||
if docker image inspect uprightbass360/azerothcore-wotlk-playerbots:authserver-Playerbot >/dev/null 2>&1; then
|
||||
IMAGES_TO_SAVE+=(uprightbass360/azerothcore-wotlk-playerbots:authserver-Playerbot)
|
||||
fi
|
||||
docker image save "${IMAGES_TO_SAVE[@]}" > "$TARBALL"
|
||||
|
||||
if [[ $SKIP_IMAGES -eq 0 ]]; then
|
||||
echo "⋅ Exporting module images to $TARBALL"
|
||||
docker image save \
|
||||
acore/ac-wotlk-worldserver:modules-latest \
|
||||
acore/ac-wotlk-authserver:modules-latest \
|
||||
> "$TARBALL"
|
||||
if [[ $SKIP_STORAGE -eq 0 ]]; then
|
||||
if [[ -d storage ]]; then
|
||||
echo "⋅ Syncing storage to remote"
|
||||
run_ssh "mkdir -p '$REMOTE_STORAGE'"
|
||||
find storage -mindepth 1 -maxdepth 1 -print0 | xargs -0 -I{} scp "${SCP_OPTS[@]}" -r '{}' "$USER@$HOST:$REMOTE_STORAGE/"
|
||||
else
|
||||
echo "⋅ Skipping storage sync (storage/ missing)"
|
||||
fi
|
||||
else
|
||||
echo "⋅ Skipping storage sync"
|
||||
fi
|
||||
|
||||
echo "⋅ Removing rebuild sentinel"
|
||||
rm -f storage/modules/.requires_rebuild || true
|
||||
|
||||
echo "⋅ Syncing project to remote $USER@$HOST:$PROJECT_DIR"
|
||||
run_ssh "mkdir -p '$PROJECT_DIR'"
|
||||
run_scp "$TMP_PROJECT_ARCHIVE" "$USER@$HOST:/tmp/acore-compose.tar.gz"
|
||||
run_ssh "tar -xzf /tmp/acore-compose.tar.gz -C '$PROJECT_DIR' --strip-components=1 && rm /tmp/acore-compose.tar.gz"
|
||||
|
||||
echo "⋅ Syncing storage to remote"
|
||||
run_ssh "mkdir -p '$REMOTE_STORAGE'"
|
||||
run_scp -r storage/* "$USER@$HOST:$REMOTE_STORAGE/"
|
||||
|
||||
if [[ $SKIP_IMAGES -eq 0 ]]; then
|
||||
echo "⋅ Transferring docker images"
|
||||
run_scp "$TARBALL" "$USER@$HOST:/tmp/acore-modules-images.tar"
|
||||
run_ssh "docker load < /tmp/acore-modules-images.tar && rm /tmp/acore-modules-images.tar"
|
||||
fi
|
||||
echo "⋅ Loading images on remote"
|
||||
run_scp "$TARBALL" "$USER@$HOST:/tmp/acore-modules-images.tar"
|
||||
run_ssh "docker load < /tmp/acore-modules-images.tar && rm /tmp/acore-modules-images.tar"
|
||||
|
||||
echo "⋅ Remote prepares completed"
|
||||
echo "Run the following on the remote host to deploy:"
|
||||
echo "Run on the remote host to deploy:"
|
||||
echo " cd $PROJECT_DIR && ./deploy.sh --skip-rebuild --no-watch"
|
||||
|
||||
rm -f "$TMP_PROJECT_ARCHIVE"
|
||||
echo "Migration script finished"
|
||||
|
||||
Reference in New Issue
Block a user