scripts: consolidate Agent deployment and remove Probe packages

Use Agent for native, container, systemd and OpenWrt installations and signed updates. Remove retired Probe deployment templates and smoke scripts.
This commit is contained in:
justme committed 2026-10-21 11:55:41 +08:00
1 parent ad5efc62ff
commit 016dbc2bbf
30 files changed
+96 -1206

No files matched your search

+1 -3
View File
@@ -2,7 +2,7 @@ FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine
ARG APP_VERSION=unknown
LABEL org.opencontainers.image.title="MoShiro Agent" \
org.opencontainers.image.description="MoShiro node agent for Linux" \
org.opencontainers.image.description="MoShiro node for Linux: listens and dials (MOSHIRO_MODE=agent) or only dials (MOSHIRO_MODE=dial)" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.version="$APP_VERSION"
@@ -12,10 +12,8 @@ COPY --chown=1654:1654 app/fleet-enroll /usr/local/bin/fleet-enroll
COPY --chown=1654:1654 config/ /etc/moshiro/
COPY --chown=1654:1654 --chmod=0755 entrypoint.sh /usr/local/bin/moshiro-entrypoint
ENV MOSHIRO_ROLE=agent
ENV LD_LIBRARY_PATH=/usr/local/bin
USER 1654:1654
WORKDIR /etc/moshiro
VOLUME ["/etc/moshiro"]
ENTRYPOINT ["/usr/local/bin/moshiro-entrypoint"]
CMD ["--config", "/etc/moshiro/agent.json"]
@@ -52,7 +52,6 @@ COPY --chown=1654:1654 --from=build /out/enroll/fleet-enroll /usr/local/bin/flee
COPY --chown=1654:1654 config/ /etc/moshiro/
COPY --chown=1654:1654 --chmod=0755 entrypoint.sh /usr/local/bin/moshiro-entrypoint
ENV MOSHIRO_ROLE=agent
USER 1654:1654
WORKDIR /etc/moshiro
VOLUME ["/etc/moshiro"]
-21
View File
@@ -1,21 +0,0 @@
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine
ARG APP_VERSION=unknown
LABEL org.opencontainers.image.title="MoShiro Probe" \
org.opencontainers.image.description="MoShiro network measurement probe for Linux" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.version="$APP_VERSION"
COPY --chown=1654:1654 app/moshiro-probe /usr/local/bin/moshiro-probe
COPY --chown=1654:1654 app/lib*.so.* /usr/local/bin/
COPY --chown=1654:1654 app/fleet-enroll /usr/local/bin/fleet-enroll
COPY --chown=1654:1654 config/ /etc/moshiro/
COPY --chown=1654:1654 --chmod=0755 entrypoint.sh /usr/local/bin/moshiro-entrypoint
ENV MOSHIRO_ROLE=probe
ENV LD_LIBRARY_PATH=/usr/local/bin
USER 1654:1654
WORKDIR /etc/moshiro
VOLUME ["/etc/moshiro"]
ENTRYPOINT ["/usr/local/bin/moshiro-entrypoint"]
CMD ["--config", "/etc/moshiro/probe.json"]
@@ -1,60 +0,0 @@
# AotAnywhere cross-links both Alpine architectures on the native amd64 runner.
ARG NATIVEAOT_BUILDER_IMAGE=localhost/moshiro-dotnet10-nativeaot-aotanywhere:ci
FROM --platform=linux/amd64 ${NATIVEAOT_BUILDER_IMAGE} AS build
WORKDIR /src/backend
COPY restore/backend/ ./
ARG NODE_RID=linux-musl-x64
ENV NUGET_PACKAGES=/root/.nuget/packages
RUN dotnet restore probe/src/MoShiro.Probe -r "$NODE_RID" -p:PublishAot=true -p:UseAotAnywhere=true \
-p:StaticMsQuic=true -p:StaticExecutable=true -p:RuntimeFrameworkVersion=10.0.12 \
-p:InvariantGlobalization=true --artifacts-path /artifacts \
&& dotnet restore fleet/tools/fleet-enroll -r "$NODE_RID" -p:PublishAot=true -p:UseAotAnywhere=true \
-p:StaticMsQuic=true -p:StaticExecutable=true -p:RuntimeFrameworkVersion=10.0.12 -p:InvariantGlobalization=true \
--artifacts-path /artifacts
COPY source/backend/ ./
COPY source/packaging/native/msquic/ /src/packaging/native/msquic/
# 构建信息:CI 通过 --build-arg 传入;不传就是空(放在 restore 之后,每次构建都变的时间不会让依赖还原的缓存失效)
ARG MOSHIRO_TAG=
ARG MOSHIRO_COMMIT=
ARG MOSHIRO_BUILT_AT=
ENV MOSHIRO_TAG=$MOSHIRO_TAG MOSHIRO_COMMIT=$MOSHIRO_COMMIT MOSHIRO_BUILT_AT=$MOSHIRO_BUILT_AT
RUN dotnet publish probe/src/MoShiro.Probe -m:3 -c Release -r "$NODE_RID" \
--self-contained true --no-restore -p:PublishAot=true -p:UseAotAnywhere=true \
-p:StaticMsQuic=true -p:StaticExecutable=true -p:RuntimeFrameworkVersion=10.0.12 \
-p:InvariantGlobalization=true -p:UseAppHost=true -p:StripSymbols=true \
-p:DebugType=none -p:DebugSymbols=false --artifacts-path /artifacts -o /out/probe \
&& dotnet publish fleet/tools/fleet-enroll -m:3 -c Release -r "$NODE_RID" \
--self-contained true --no-restore -p:PublishAot=true -p:UseAotAnywhere=true \
-p:StaticMsQuic=true -p:StaticExecutable=true -p:RuntimeFrameworkVersion=10.0.12 -p:InvariantGlobalization=true \
-p:UseAppHost=true -p:StripSymbols=true \
-p:DebugType=none -p:DebugSymbols=false --artifacts-path /artifacts -o /out/enroll \
&& rm -rf /artifacts
RUN test -x /out/probe/moshiro-probe && test -x /out/enroll/fleet-enroll \
&& test "$(stat -c%s /out/probe/moshiro-probe)" -gt 2000000 \
&& test "$(stat -c%s /out/enroll/fleet-enroll)" -gt 2000000 \
&& ! readelf -l /out/probe/moshiro-probe | grep -q INTERP \
&& ! readelf -d /out/probe/moshiro-probe 2>&1 | grep -q NEEDED \
&& ! readelf -l /out/enroll/fleet-enroll | grep -q INTERP \
&& ! readelf -d /out/enroll/fleet-enroll 2>&1 | grep -q NEEDED
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine
ARG APP_VERSION=main
LABEL org.opencontainers.image.title="MoShiro Probe" \
org.opencontainers.image.description="MoShiro network measurement probe for Linux" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.version="$APP_VERSION"
COPY --chown=1654:1654 --from=build /out/probe/moshiro-probe /usr/local/bin/moshiro-probe
COPY --chown=1654:1654 --from=build /out/enroll/fleet-enroll /usr/local/bin/fleet-enroll
COPY --chown=1654:1654 config/ /etc/moshiro/
COPY --chown=1654:1654 --chmod=0755 entrypoint.sh /usr/local/bin/moshiro-entrypoint
ENV MOSHIRO_ROLE=probe
USER 1654:1654
WORKDIR /etc/moshiro
VOLUME ["/etc/moshiro"]
ENTRYPOINT ["/usr/local/bin/moshiro-entrypoint"]
CMD ["--config", "/etc/moshiro/probe.json"]
+5 -18
View File
@@ -1,24 +1,22 @@
#!/bin/sh
# 部署或更新容器服务(Agent、Probe;Backend 用 Quadlet,见 packaging/quadlet/moshiro-backend.container)。可以重复运行:每次都会拉取镜像、把配置迁移到当前版本需要的样子、
# 部署或更新容器服务(Agent;Backend 用 Quadlet,见 packaging/quadlet/moshiro-backend.container)。可以重复运行:每次都会拉取镜像、把配置迁移到当前版本需要的样子、
# 重新安装单元和更新器,然后重启节点;已有的身份和配置不会被覆盖。
#
# 首次部署 Agent:sudo sh deploy-node.sh agent --image-repo REPO --server https://panel --join jt_xxx --name hk-1
# 首次部署 Probe:sudo sh deploy-node.sh probe --image-repo REPO --server https://panel --join jt_xxx --name home-1
# 更新(配置迁移、单元和更新器、镜像):sudo sh deploy-node.sh agent (其余参数沿用上次的更新器配置)
# 旧版 Probe(probe.json 里没有 fleet 段):加上 --server --join --name 重新运行即可,旧文件备份为 probe.json.old
#
# 需要 root、systemd,以及 Podman 或 Docker;脚本要和 packaging/ 里的 systemd/、update/ 放在一起。
# rootless Podman 见 docs/ops/deployment.md。
set -eu
usage() {
echo "usage: deploy-node.sh <agent|probe> [--engine podman|docker] [--image-repo R] [--channel dev|release] [--tag T] [--image REF]" >&2
echo "usage: deploy-node.sh <agent> [--engine podman|docker] [--image-repo R] [--channel dev|release] [--tag T] [--image REF]" >&2
echo " [--server URL --join TOKEN --name NAME] [--policy auto|manual] [--authfile F]" >&2
exit 2
}
ROLE="${1:-}"; shift || true
case "$ROLE" in agent|probe) ;; *) usage ;; esac
case "$ROLE" in agent) ;; *) usage ;; esac
ENGINE=""; REPO=""; TAG=""; IMAGE=""; SERVER=""; JOIN=""; NAME=""; POLICY=""; AUTHFILE=""; CHANNEL=""
while [ $# -gt 0 ]; do
case "$1" in
@@ -121,7 +119,7 @@ in_volume() {
}
in_volume 'mkdir -p /etc/moshiro/update' </dev/null
# 3. 配置:身份由节点自己生成(Agent 和 Probe 一样),注册之后面板只认这把公钥
# 3. 配置:身份由节点自己生成(所有 Agent 一样),注册之后面板只认这把公钥
ID_DIR="/etc/moshiro/$ROLE-id"
if ! in_volume "test -f $ID_DIR/node.json" </dev/null; then
[ -n "$SERVER" ] && [ -n "$JOIN" ] && [ -n "$NAME" ] || { echo "first deployment needs --server, --join and --name" >&2; exit 1; }
@@ -139,18 +137,7 @@ if [ "$ROLE" = agent ]; then
in_volume 'sed -i "s/\"bind\" *: *\"0\.0\.0\.0\"/\"bind\": \"::\"/" /etc/moshiro/agent.json' </dev/null
echo "config: listen.bind 0.0.0.0 -> ::"
fi
elif [ "$ROLE" = probe ]; then
# 旧格式(面板生成的 probe.json:没有 fleet 段)备份之后按新格式重写
if in_volume 'test -f /etc/moshiro/probe.json' </dev/null && ! in_volume 'grep -q "\"fleet\"" /etc/moshiro/probe.json' </dev/null; then
in_volume 'mv /etc/moshiro/probe.json /etc/moshiro/probe.json.old' </dev/null
echo "config: old probe.json moved to probe.json.old"
fi
if ! in_volume 'test -f /etc/moshiro/probe.json' </dev/null; then
[ -n "$SERVER" ] || { echo "probe.json is missing; pass --server to create it" >&2; exit 1; }
printf '{"fleet":{"server":"%s","identity_dir":"/etc/moshiro/probe-id"}}\n' "$SERVER" \
| in_volume 'umask 077; cat > /etc/moshiro/probe.json'
echo "config: created probe.json"
fi
fi
# 4. 单元和更新器(保持原来的更新策略)
+5 -8
View File
@@ -1,9 +1,10 @@
#!/bin/sh
# 容器入口(Agent 和 Probe 共用):第一次启动用 MOSHIRO_SERVER / MOSHIRO_JOIN(MOSHIRO_NAME 不写就用主机名)自己注册并写配置,
# 容器入口(监听和拨号两种模式共用,镜像里只有 moshiro-agent):第一次启动用 MOSHIRO_SERVER / MOSHIRO_JOIN(MOSHIRO_NAME 不写就用主机名)自己注册并写配置,
# 身份和配置都在命名卷 /etc/moshiro 里,之后重启(或换新镜像重建容器)直接启动,不需要再给参数。
set -eu
role="${MOSHIRO_ROLE:?MOSHIRO_ROLE is set by the image}"
# 所有节点默认同时监听和拨号,身份与配置统一保存。
role=agent
# Quadlet 单元和 compose 默认用宿主网络;Docker Desktop(没有宿主网络)的 .env 里写 MOSHIRO_NETWORK_SCOPE=container
export MOSHIRO_NETWORK_SCOPE="${MOSHIRO_NETWORK_SCOPE:-host}"
dir=/etc/moshiro
@@ -39,11 +40,7 @@ if [ ! -f "$config" ]; then
echo "$config is missing: set MOSHIRO_SERVER to create it" >&2
exit 1
fi
if [ "$role" = agent ]; then
printf '{"fleet":{"server":"%s","identity_dir":"%s"},"listen":{"bind":"::"}}\n' "$MOSHIRO_SERVER" "$identity" > "$config"
else
printf '{"fleet":{"server":"%s","identity_dir":"%s"}}\n' "$MOSHIRO_SERVER" "$identity" > "$config"
fi
printf '{"fleet":{"server":"%s","identity_dir":"%s"},"listen":{"bind":"::"}}\n' "$MOSHIRO_SERVER" "$identity" > "$config"
fi
exec "/usr/local/bin/moshiro-$role" "$@"
exec /usr/local/bin/moshiro-agent --config "$config" "$@"