forked from lei.chen/myxce
feat(admin-config-tool): task 4.2 - deploy-ha.sh --build-config
Add --build-config (parsed anywhere in the arg list) that rebuilds <data-dir>/cluster.bin from configs/ via the venv's xceadmin before deploying; a missing cluster.bin auto-builds the same way even without the flag. An existing cluster.bin with no flag passed is left byte-for-byte untouched, matching prior behavior. xceadmin and the configs source are resolved relative to the script's own location, not the caller's CWD. Verified live: missing-file auto-build, untouched-when-present (same mtime/SHA), and forced rebuild reproducing byte-identical output.
This commit is contained in:
parent
eeda32c696
commit
ad27147a59
2 changed files with 33 additions and 6 deletions
|
|
@ -1,19 +1,45 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BINARY=$1
|
||||
DATADIR=$2
|
||||
TOP=$3
|
||||
PEERS=$4
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
# --build-config may appear anywhere among the positional args.
|
||||
BUILD_CONFIG=0
|
||||
ARGS=()
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = "--build-config" ]; then
|
||||
BUILD_CONFIG=1
|
||||
else
|
||||
ARGS+=("$arg")
|
||||
fi
|
||||
done
|
||||
|
||||
BINARY=${ARGS[0]}
|
||||
DATADIR=${ARGS[1]}
|
||||
TOP=${ARGS[2]}
|
||||
PEERS=${ARGS[3]}
|
||||
|
||||
if [ -z "$BINARY" ] || [ -z "$DATADIR" ] || [ -z "$TOP" ] || [ -z "$PEERS" ]; then
|
||||
echo "Usage: $0 <binary> <data-dir> <top-dir> <peers>"
|
||||
echo "Usage: $0 [--build-config] <binary> <data-dir> <top-dir> <peers>"
|
||||
echo " --build-config: rebuild <data-dir>/cluster.bin from configs/ before deploying,"
|
||||
echo " even if one already exists"
|
||||
echo " peers: comma-separated host:port list (e.g. host1:port1,host2:port2)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BINARY=$(realpath "$BINARY")
|
||||
|
||||
# Requirements 8.3/8.4/8.5: rebuild cluster.bin when --build-config is
|
||||
# passed or none exists yet; otherwise leave an existing one untouched.
|
||||
if [ "$BUILD_CONFIG" = "1" ] || [ ! -f "$DATADIR/cluster.bin" ]; then
|
||||
XCEADMIN="$SCRIPT_DIR/../xceadmin/.venv/bin/xceadmin"
|
||||
if [ ! -x "$XCEADMIN" ]; then
|
||||
echo "Error: $XCEADMIN not found -- run 'xce-build.sh xceadmin' first"
|
||||
exit 1
|
||||
fi
|
||||
"$XCEADMIN" config build "$SCRIPT_DIR/../configs" -o "$DATADIR/cluster.bin"
|
||||
fi
|
||||
|
||||
IFS=',' read -ra PEER_ARRAY <<< "$PEERS"
|
||||
N=${#PEER_ARRAY[@]}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue