Use Agent for native, container, systemd and OpenWrt installations and signed updates. Remove retired Probe deployment templates and smoke scripts.
43 lines
2.2 KiB
Bash
43 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
||
# 打包:scripts/package.sh <agent> <rid> → backend/artifacts/packages/moshiro-<role>-<version>-<rid>.tar.gz(附 .sha256)
|
||
# 内容:节点二进制(agent 还带 fleet-enroll)、systemd 单元、OpenWrt procd 脚本、install.sh。
|
||
# 发布产物要先用 scripts/publish.sh 生成(agent 需要 agent 和 fleet-enroll 两个)。
|
||
set -euo pipefail
|
||
role="${1:?usage: package.sh <agent> <rid>}"
|
||
rid="${2:?usage: package.sh <agent> <rid>}"
|
||
[[ "$role" == agent ]] || { echo "only agent packages are supported" >&2; exit 2; }
|
||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||
version="$(sed -n 's#.*<Version>\(.*\)</Version>.*#\1#p' "$root/backend/Directory.Build.props" | head -1)"
|
||
name="moshiro-$role-$version-$rid"
|
||
stage="$root/backend/artifacts/packages/stage/$name"
|
||
quic_runtime="$root/backend/artifacts/packages/quic-runtime/$rid"
|
||
|
||
rm -rf "$stage"
|
||
mkdir -p "$stage/systemd"
|
||
if [[ "$rid" == linux-* ]]; then
|
||
if command -v pwsh >/dev/null 2>&1; then
|
||
pwsh -NoProfile -File "$root/ci/Bundle-QuicRuntime.ps1" -RuntimeIdentifier "$rid" -Destination "$quic_runtime"
|
||
elif command -v pwsh.exe >/dev/null 2>&1 && command -v wslpath >/dev/null 2>&1; then
|
||
pwsh.exe -NoProfile -File "$(wslpath -w "$root/ci/Bundle-QuicRuntime.ps1")" -RuntimeIdentifier "$rid" -Destination "$(wslpath -w "$quic_runtime")"
|
||
else
|
||
echo "PowerShell 7 is required to bundle the Linux QUIC runtime" >&2
|
||
exit 2
|
||
fi
|
||
cp "$quic_runtime"/*.so.* "$stage/"
|
||
fi
|
||
cp "$root/backend/artifacts/publish/$role/$rid/moshiro-$role" "$stage/"
|
||
cp "$root/packaging/install.sh" "$stage/"
|
||
cp "$root/packaging/systemd/moshiro-$role.service" "$stage/systemd/"
|
||
cp "$root/backend/$role/README.md" "$stage/README.md"
|
||
if [ "$role" = agent ]; then
|
||
cp "$root/backend/artifacts/publish/fleet-enroll/$rid/fleet-enroll" "$stage/"
|
||
fi
|
||
if [[ "$rid" == linux-* ]]; then
|
||
mkdir -p "$stage/openwrt"
|
||
cp "$root/packaging/openwrt/"* "$stage/openwrt/"
|
||
fi
|
||
|
||
mkdir -p "$root/backend/artifacts/packages"
|
||
tar -C "$root/backend/artifacts/packages/stage" -czf "$root/backend/artifacts/packages/$name.tar.gz" "$name"
|
||
(cd "$root/backend/artifacts/packages" && sha256sum "$name.tar.gz" > "$name.tar.gz.sha256" && ls -l "$name.tar.gz" && cat "$name.tar.gz.sha256")
|