Files
MoShiro/scripts/package.sh
T
justme 2e146d4da7
ci/woodpecker/push/main-amd64-build Pipeline was successful
refactor!: rename the project from Monitor to MoShiro [CI]
Namespaces, assemblies, solution, binaries, images, systemd units, config paths, environment variables, protocol methods and the Linux user are all renamed. Breaking: existing databases, node identities and installed units must be recreated.
2026-10-07 02:03:25 +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")