[#37] 优化client安装包
This commit is contained in:
parent
3202e02b42
commit
3551360687
@ -52,5 +52,14 @@ out_name="argus-metric_$(echo "$VERSION" | sed 's/\./_/g').tar.gz"
|
|||||||
log "Client package ready: $PKG_DIR/$out_name"
|
log "Client package ready: $PKG_DIR/$out_name"
|
||||||
echo "$VERSION" > "$PKG_DIR/LATEST_VERSION"
|
echo "$VERSION" > "$PKG_DIR/LATEST_VERSION"
|
||||||
|
|
||||||
exit 0
|
# include publish helper and setup.sh for convenience
|
||||||
|
PUBLISH_TPL="$BUILD_DIR/templates/client/publish.sh"
|
||||||
|
if [[ -f "$PUBLISH_TPL" ]]; then
|
||||||
|
cp "$PUBLISH_TPL" "$PKG_DIR/publish.sh" && chmod +x "$PKG_DIR/publish.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# also place a copy of setup.sh alongside
|
||||||
|
SETUP_SRC="$ROOT_DIR/src/metric/client-plugins/all-in-one-full/scripts/setup.sh"
|
||||||
|
[[ -f "$SETUP_SRC" ]] && cp "$SETUP_SRC" "$PKG_DIR/setup.sh" || true
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
||||||
. "$ROOT_DIR/build/common.sh"
|
|
||||||
|
|
||||||
usage() { cat <<'EOF'
|
|
||||||
Publish client package to FTP server
|
|
||||||
|
|
||||||
Usage: publish_client.sh --version YYYYMMDD --server HOST --user USER --password PASS [--port 21]
|
|
||||||
|
|
||||||
It uploads: setup.sh, argus-metric_<YYYYMMDD>.tar.gz, LATEST_VERSION to the FTP share root.
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
VERSION=""; HOST=""; USERNAME=""; PASSWORD=""; PORT=21
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case "$1" in
|
|
||||||
--version) VERSION="$2"; shift 2;;
|
|
||||||
--server) HOST="$2"; shift 2;;
|
|
||||||
--user) USERNAME="$2"; shift 2;;
|
|
||||||
--password) PASSWORD="$2"; shift 2;;
|
|
||||||
--port) PORT="$2"; shift 2;;
|
|
||||||
-h|--help) usage; exit 0;;
|
|
||||||
*) err "unknown arg: $1"; usage; exit 1;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
[[ -n "$VERSION" && -n "$HOST" && -n "$USERNAME" && -n "$PASSWORD" ]] || { usage; exit 1; }
|
|
||||||
|
|
||||||
CLIENT_DIR="$ROOT_DIR/artifact/client/$VERSION"
|
|
||||||
TAR_NAME="argus-metric_${VERSION}.tar.gz"
|
|
||||||
PKG="$CLIENT_DIR/$TAR_NAME"
|
|
||||||
SETUP_SRC="$ROOT_DIR/../src/sys/tests/private/argus/metric/ftp/share/setup.sh"
|
|
||||||
ALT_SETUP="$ROOT_DIR/../src/metric/client-plugins/all-in-one-full/scripts/setup.sh"
|
|
||||||
|
|
||||||
[[ -f "$PKG" ]] || { err "missing client package: $PKG"; exit 1; }
|
|
||||||
if [[ ! -f "$SETUP_SRC" ]]; then
|
|
||||||
if [[ -f "$ALT_SETUP" ]]; then
|
|
||||||
SETUP_SRC="$ALT_SETUP"
|
|
||||||
else
|
|
||||||
err "missing setup.sh (checked $SETUP_SRC and $ALT_SETUP)"; exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "Uploading setup.sh"
|
|
||||||
curl -u "$USERNAME:$PASSWORD" -sfT "$SETUP_SRC" "ftp://$HOST:$PORT/setup.sh"
|
|
||||||
|
|
||||||
log "Uploading client tar: $TAR_NAME"
|
|
||||||
curl -u "$USERNAME:$PASSWORD" -sfT "$PKG" "ftp://$HOST:$PORT/$TAR_NAME"
|
|
||||||
|
|
||||||
log "Updating LATEST_VERSION -> $VERSION"
|
|
||||||
printf "%s" "$VERSION" | curl -u "$USERNAME:$PASSWORD" -sfT - "ftp://$HOST:$PORT/LATEST_VERSION"
|
|
||||||
|
|
||||||
log "Publish done"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
54
deployment/build/templates/client/publish.sh
Normal file
54
deployment/build/templates/client/publish.sh
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
usage() { cat <<'EOF'
|
||||||
|
Publish Argus client package to FTP
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
./publish.sh --server HOST --user USER --password PASS [--port 21]
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- This script expects to run inside the built client artifact directory.
|
||||||
|
- It reads LATEST_VERSION and uploads setup.sh, argus-metric_<ver>.tar.gz, and LATEST_VERSION.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
HOST=""; USERNAME=""; PASSWORD=""; PORT=21
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--server) HOST="$2"; shift 2;;
|
||||||
|
--user) USERNAME="$2"; shift 2;;
|
||||||
|
--password) PASSWORD="$2"; shift 2;;
|
||||||
|
--port) PORT="$2"; shift 2;;
|
||||||
|
-h|--help) usage; exit 0;;
|
||||||
|
*) echo "unknown arg: $1" >&2; usage; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ -n "$HOST" && -n "$USERNAME" && -n "$PASSWORD" ]] || { usage; exit 1; }
|
||||||
|
|
||||||
|
here="$(pwd)"
|
||||||
|
if [[ ! -f "$here/LATEST_VERSION" ]]; then
|
||||||
|
echo "LATEST_VERSION not found in $(pwd)" >&2; exit 1;
|
||||||
|
fi
|
||||||
|
VER=$(cat "$here/LATEST_VERSION" | tr -d '\n')
|
||||||
|
PKG="argus-metric_${VER}.tar.gz"
|
||||||
|
|
||||||
|
if [[ ! -f "$here/$PKG" ]]; then
|
||||||
|
echo "client tar not found: $PKG" >&2; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# locate setup.sh (prefer colocated, fallback to bundled path if provided)
|
||||||
|
SETUP="${here}/setup.sh"
|
||||||
|
if [[ ! -f "$SETUP" ]]; then
|
||||||
|
echo "setup.sh not found in $(pwd)" >&2; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[PUBLISH] server=$HOST port=$PORT version=$VER"
|
||||||
|
|
||||||
|
curl -u "$USERNAME:$PASSWORD" -sfT "$SETUP" "ftp://$HOST:$PORT/setup.sh"
|
||||||
|
curl -u "$USERNAME:$PASSWORD" -sfT "$PKG" "ftp://$HOST:$PORT/$PKG"
|
||||||
|
printf "%s" "$VER" | curl -u "$USERNAME:$PASSWORD" -sfT - "ftp://$HOST:$PORT/LATEST_VERSION"
|
||||||
|
|
||||||
|
echo "[OK] publish completed"
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user