Files
MoShiro/scripts/package.sh
T
justme 83e5120377 refactor!: rename the project from Monitor to MoShiro
Namespaces, assemblies, projects and directories, the solution, binaries,
images, systemd units, config paths, environment variables, protocol method
names, the media type and the raw chunk magic all move to MoShiro/moshiro.
Existing data and deployments are not compatible and must be recreated.
Also fix the architecture tests after the solution layout change and make
the update tests independent of their order.
2026-10-07 01:49:04 +08:00

29 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 打包:scripts/package.sh <agent|probe> <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|probe> <rid>}"
rid="${2:?usage: package.sh <agent|probe> <rid>}"
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
version="$(sed -n 's#.*<Version>\(.*\)</Version>.*#\1#p' "$root/Directory.Build.props" | head -1)"
name="moshiro-$role-$version-$rid"
stage="$root/backend/artifacts/packages/stage/$name"
rm -rf "$stage"
mkdir -p "$stage/systemd"
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/$role/README.md" "$stage/README.md"
if [ "$role" = agent ]; then
cp "$root/backend/artifacts/publish/fleet-enroll/$rid/fleet-enroll" "$stage/"
else
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")