16 Commits
Author SHA1 Message Date
wangdefa 596ffc1567 feat: 重构 CI/CD 流水线,拆分为独立的构建和发布流程,更新相关文档和脚本
CI / validate (push) Successful in 5s
CI / build (amd64) (push) Successful in 3m38s
CI / build (arm64) (push) Successful in 8m39s
Release / build (amd64) (push) Successful in 3m35s
Release / build (arm64) (push) Successful in 8m58s
Release / release (push) Successful in 42s
- 新增 .gitea/workflows/ci.yml,包含版本校验、构建和冒烟测试
- 新增 .gitea/workflows/release.yml,处理 tag 发布,上传包到仓库并创建 Release
- 更新 README.md 和 CLAUDE.md,描述新的 CI/CD 流程和版本号约定
- 修改 init.sh,增加对关键锚点的检查,确保源码结构一致性
- 更新 Dockerfile,使用 OpenSSL 3.0.21 和 unbound 1.25.1,确保与 Monero 版本一致
- 更新 build-deb.sh 示例,反映最新版本号
- 新增 VERSION 文件,统一版本管理
2026-08-07 09:51:47 +08:00
wangdefaandClaude Opus 4.8 4b587550a1 精简 README,对齐 xxxig/p2pool 等项目风格
Build and Release Mond / build-and-test (amd64) (push) Successful in 5s
Build and Release Mond / build-and-test (arm64) (push) Successful in 31s
Build and Release Mond / release (push) Has been skipped
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:00:49 +08:00
wangdefaandClaude Opus 4.8 b44b118be7 改用 musl 全静态构建,零依赖跨发行版
Build and Release Mond / release (push) Successful in 19s
Build and Release Mond / build-and-test (amd64) (push) Successful in 4m11s
Build and Release Mond / build-and-test (arm64) (push) Successful in 9m19s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 12:03:43 +08:00
wangdefaandClaude Opus 4.8 5430297ff9 fix: 版本变量改 PACKAGE_VERSION、CI 触发 tags['*']、修正静态措辞
Build and Release Mond / build-and-test (amd64) (push) Successful in 1s
Build and Release Mond / build-and-test (arm64) (push) Successful in 35s
Build and Release Mond / release (push) Successful in 16s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 22:30:53 +08:00
wangdefaandClaude Opus 4.8 317973e94d feat: 对齐 xxxig/proxy 打包规范并迁移配置至 /etc/mond
Build and Release Mond / build-and-test (amd64) (push) Successful in 11m47s
Build and Release Mond / build-and-test (arm64) (push) Successful in 18m24s
Build and Release Mond / release (push) Has been skipped
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 22:00:48 +08:00
wangdefa 2862374985 feat: 更新 Monero 版本至 v0.18.4.6,并调整相关文档和脚本
Build and Release Mond / build-and-test (arm64) (push) Successful in -17s
Build and Release Mond / build-and-test (amd64) (push) Successful in -1m16s
Build and Release Mond / release (push) Successful in -1m6s
2026-03-14 16:42:07 +08:00
wangdefa 1faa92266e fix: 修复 apt 升级后服务需要手动重新启用的问题
Build and Release Mond / build-and-test (arm64) (push) Successful in -17s
Build and Release Mond / build-and-test (amd64) (push) Successful in -19s
Build and Release Mond / release (push) Has been skipped
- 修改 prerm 脚本,升级时只停止服务不禁用
- 修改 postinst 脚本,升级后自动重启已启用的服务
- 首次安装仍保持手动启用服务的行为
2026-01-21 12:40:29 +08:00
wangdefa 2d47652a06 feat: 更新 .gitignore 文件,添加 macOS 系统文件排除项
Build and Release Mond / build-and-test (arm64) (push) Successful in -18s
Build and Release Mond / build-and-test (amd64) (push) Successful in -18s
Build and Release Mond / release (push) Successful in -3s
2026-01-21 12:01:31 +08:00
wangdefa b70d968390 feat: 删除过时的文档文件,精简项目文档结构 2026-01-21 11:59:29 +08:00
wangdefa 319cadb352 feat: 更新 Monero 版本至 v0.18.4.5,并调整相关文档和配置
Build and Release Mond / build-and-test (amd64) (push) Successful in 11m52s
Build and Release Mond / build-and-test (arm64) (push) Successful in 18m1s
Build and Release Mond / release (push) Has been skipped
2026-01-21 11:56:40 +08:00
wangdefa b491d8af32 ci: 统一 Debian 发布为 stable 发行版并更新相关文档
Build and Release Mond / build-and-test (arm64) (push) Successful in 2s
Build and Release Mond / build-and-test (amd64) (push) Successful in 16s
Build and Release Mond / release (push) Successful in 28s
- 去除多发行版支持(bookworm、trixie),改为 stable 单一发行版
- 更新 CI 配置:Debian 包统一上传到 debian/pool/stable/main
- 简化 Release 说明生成脚本
- 更新安装指南、发布指南和 CI/CD 架构文档
- 补充系统设计和配置参考文档
2025-12-25 10:55:04 +08:00
wangdefa b13d06aae7 feat: 优化配置文件格式并完善文档系统
Build and Release Mond / build-and-test (arm64) (push) Successful in 5s
Build and Release Mond / build-and-test (amd64) (push) Successful in 15s
Build and Release Mond / release (push) Has been skipped
- 新增详细配置示例文件(conf/params.example.conf),包含所有配置项的详细中文说明
- 配置文件采用清晰的章节分组和双语注释(英文标题 + 中文说明)
- 新增配置项:sync-pruned-blocks、limit-rate-up、limit-rate-down
- 默认启用 P2P 网络绑定(0.0.0.0:18080)
- 更新项目文档索引并同步配置参考文档
2025-12-24 10:43:51 +08:00
wangdefa ff86a4e2bf feat: 优化 Debian 打包配置并初始化项目文档系统
Build and Release Mond / build-and-test (arm64) (push) Successful in 4s
Build and Release Mond / build-and-test (amd64) (push) Successful in 14s
Build and Release Mond / release (push) Successful in 37s
- 简化 mond.service 配置,改为通过配置文件启动
- 优化 postinst 安装脚本,自动生成配置文件模板
- 优化 postrm 卸载脚本,正确清理数据目录
- 初始化 llmdoc 文档系统,包含项目概览、使用指南、架构说明和参考文档
- 更新 README.md 构建和配置说明
- 移除 .gitignore 中 llmdoc/ 的忽略规则
2025-12-24 08:59:06 +08:00
wangdefa 78f66b3c23 ci: Release 描述改为中文并移除静态链接验证
Build and Release Mond / build-and-test (arm64) (push) Successful in 41s
Build and Release Mond / build-and-test (amd64) (push) Successful in 53s
Build and Release Mond / release (push) Has been skipped
- 将 Release 说明翻译为简体中文
- 移除 'Verify Static Linking' 部分
- 优化下载方式说明的中文表述
2025-12-15 15:03:21 +08:00
wangdefa 9e57ed1690 feat: 优化 mond.service 配置
Build and Release Mond / build-and-test (arm64) (push) Successful in 39s
Build and Release Mond / build-and-test (amd64) (push) Successful in 51s
Build and Release Mond / release (push) Successful in 1m17s
添加生产环境优化配置:
- 启用区块链修剪(--prune-blockchain)
- 配置 ZMQ 发布端点(tcp://127.0.0.1:18083)
- 优化节点连接数(out-peers: 32, in-peers: 64)
- 添加优先节点(xmrvsbeast, hashvault)
- 启用 DNS 检查点和黑名单
- 设置日志级别为 1
- 非交互模式运行
2025-12-15 14:57:51 +08:00
wangdefa 89f909606c ci: 移除静态链接验证步骤 2025-12-15 14:56:53 +08:00
17 changed files with 947 additions and 591 deletions
-238
View File
@@ -1,238 +0,0 @@
# .gitea/workflows/ci.yaml
name: Build and Release Mond
on:
push:
branches: [main, master, develop]
tags: ['v*']
env:
DOCKER_BUILDKIT: "1"
PRODUCT_NAME: "mond"
MONERO_VERSION: "v0.18.4.4"
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
jobs:
build-and-test:
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest-amd64' || 'ubuntu-latest-arm64' }}
strategy:
matrix:
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- name: Setup Docker Buildx
run: |
# 创建 buildx builder(原生构建不需要 QEMU)
docker buildx create --use --name native-builder \
--driver docker-container \
--driver-opt network=host \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=50000000 \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000 \
|| true
docker buildx inspect --bootstrap
- name: Build binaries
run: |
PLATFORM="linux/${{ matrix.arch }}"
echo "🏗️ Building ${PLATFORM} on native ${{ matrix.arch }} runner"
echo "📦 Using Ubuntu 20.04 with depends system"
echo "📦 Monero Version: ${MONERO_VERSION}"
echo "🔗 Static linking enabled"
# 设置 BuildKit 优化参数
export BUILDKIT_PROGRESS=plain
docker buildx build --pull \
--platform ${PLATFORM} \
--build-arg MONERO_VERSION=${MONERO_VERSION} \
--output type=local,dest=./output \
-f docker/Dockerfile.ubuntu .
- name: Verify static linking
run: |
DIR="./output/linux_${{ matrix.arch }}"
BINARY="${DIR}/mond"
if [ ! -f "$BINARY" ]; then
echo "❌ 二进制文件不存在: $BINARY"
exit 1
fi
echo "🔍 验证静态链接..."
if ldd "$BINARY" 2>&1 | grep -q "not a dynamic executable"; then
echo "✅ 纯静态链接验证成功"
else
echo "❌ 静态链接验证失败,发现动态库依赖:"
ldd "$BINARY" || true
exit 1
fi
file "$BINARY"
- name: Package and test
run: |
DIR="./output/linux_${{ matrix.arch }}"
VERSION=${MONERO_VERSION#v} # 移除前导 v
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-ubuntu-${VERSION}.tar.gz"
tar -czf "${TARGZ}" -C "$DIR" .
echo "📦 Created package: ${TARGZ}"
ls -lh "${TARGZ}"
# 快速验证
mkdir -p test && tar -xzf "${TARGZ}" -C test
test/mond --version 2>/dev/null || echo "⚠️ 跳过版本检查"
rm -rf test
- name: Build Debian package
run: |
# 安装 dpkg-deb(如果需要)
sudo apt-get update && sudo apt-get install -y dpkg-dev
DIR="./output/linux_${{ matrix.arch }}"
VERSION=${MONERO_VERSION#v} # 移除前导 v
echo "📦 Building Debian package for ${{ matrix.arch }}..."
chmod +x debian/build-deb.sh
./debian/build-deb.sh ${{ matrix.arch }} ${VERSION} "${DIR}"
ls -lh *.deb
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
with:
name: binaries-${{ matrix.arch }}
path: |
*.tar.gz
*.deb
retention-days: 1
release:
runs-on: ubuntu-latest-amd64
needs: build-and-test
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: https://github.com/ChristopherHX/gitea-download-artifact@v4
with:
pattern: binaries-*
path: ./packages
merge-multiple: true
- name: Upload packages and create release
env:
TOKEN: ${{ secrets.BUILD_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
cd packages
# 提取仓库信息(移除 https:// 前缀和仓库路径)
REGISTRY=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
OWNER="${{ gitea.repository_owner }}"
REPO_NAME=$(echo "${{ gitea.repository }}" | cut -d'/' -f2)
echo "📦 上传包到 Generic Package Registry..."
echo " Registry: ${REGISTRY}"
echo " Owner: ${OWNER}"
echo " Package: ${PRODUCT_NAME}"
echo " Version: ${TAG}"
# 上传所有 tar.gz 包到 Generic Package Registry
for file in *.tar.gz; do
[ ! -f "$file" ] && continue
echo " ⬆️ $file"
curl -fsSL -X PUT \
-H "Authorization: token ${TOKEN}" \
--upload-file "$file" \
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${TAG}/$file" || {
echo "❌ 上传失败: $file"
exit 1
}
done
# 上传 Debian 包到 Debian Package Registry (支持多个发行版)
echo ""
echo "📦 上传 Debian 包到 Debian Package Registry..."
for file in *.deb; do
[ ! -f "$file" ] && continue
# 上传到 bookworm (Debian 12)
echo " ⬆️ $file → bookworm"
curl -fsSL -X PUT \
-H "Authorization: token ${TOKEN}" \
--upload-file "$file" \
"https://${REGISTRY}/api/packages/${OWNER}/debian/pool/bookworm/main/upload" || {
echo "❌ Debian 包上传失败: $file (bookworm)"
exit 1
}
# 上传到 trixie (Debian 13)
echo " ⬆️ $file → trixie"
curl -fsSL -X PUT \
-H "Authorization: token ${TOKEN}" \
--upload-file "$file" \
"https://${REGISTRY}/api/packages/${OWNER}/debian/pool/trixie/main/upload" || {
echo "❌ Debian 包上传失败: $file (trixie)"
exit 1
}
done
# 生成 Release JSON payload
echo ""
echo "📝 生成 Release..."
export REGISTRY OWNER TAG
RELEASE_DATA=$(python3 -c 'import json,glob,os;r=os.environ["REGISTRY"];o=os.environ["OWNER"];p=os.environ["PRODUCT_NAME"];t=os.environ["TAG"];b=["## Release "+t,"","Mond is a customized build of Monero daemon (monerod).","","### ✨ Key Features","","- 🔗 **Pure Static Linking** - No dependencies required, runs on any Linux system","- 🏗️ **Multi-Architecture** - Native support for AMD64 and ARM64","- 📦 **Built with Official depends System** - Using Monero official build system for reliability","","### 📥 Download Methods","","#### Method 1: Direct Download (Recommended)","","Click on the file names in the **Assets** section below to download directly.","","**Available Packages:**",""]+[f"- [`{f}`](https://{r}/api/packages/{o}/generic/{p}/{t}/{f})" for f in sorted(glob.glob("*.tar.gz"))]+["","#### Method 2: Generic Package Registry","","Download via command line:",""]+[f"```bash\nwget https://{r}/api/packages/{o}/generic/{p}/{t}/{f}\n```" for f in sorted(glob.glob("*.tar.gz"))[:1]]+["","#### Method 3: Debian Repository","","**Debian 12 (Bookworm):**","","```bash","# Download GPG key",f"sudo curl https://{r}/api/packages/{o}/debian/repository.key -o /etc/apt/keyrings/gitea-{o}.asc","","# Add repository",f"echo \"deb [signed-by=/etc/apt/keyrings/gitea-{o}.asc] https://{r}/api/packages/{o}/debian bookworm main\" | sudo tee -a /etc/apt/sources.list.d/{o}.list","","# Update and install","sudo apt-get update","sudo apt-get install mond","```","","**Debian 13 (Trixie):**","","```bash","# Download GPG key",f"sudo curl https://{r}/api/packages/{o}/debian/repository.key -o /etc/apt/keyrings/gitea-{o}.asc","","# Add repository",f"echo \"deb [signed-by=/etc/apt/keyrings/gitea-{o}.asc] https://{r}/api/packages/{o}/debian trixie main\" | sudo tee -a /etc/apt/sources.list.d/{o}.list","","# Update and install","sudo apt-get update","sudo apt-get install mond","```","","### 🔍 Verify Static Linking","","After downloading, verify the binary is statically linked:","","```bash","ldd mond","# Expected output: \"not a dynamic executable\"","```"];print(json.dumps({"tag_name":t,"name":f"Release {t}","body":"\n".join(b),"draft":False,"prerelease":False}))')
# 创建 Release
echo ""
echo "🎉 创建 Release..."
RESPONSE=$(curl -fsSL -w "\n%{http_code}" -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases" \
-d "${RELEASE_DATA}")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$RESPONSE" | head -n-1)
if [ "$HTTP_CODE" = "201" ]; then
echo "✅ Release 创建成功"
RELEASE_ID=$(echo "$RESPONSE_BODY" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
echo " Release ID: ${RELEASE_ID}"
elif [ "$HTTP_CODE" = "409" ]; then
echo "⚠️ Release 已存在,获取现有 Release ID..."
RELEASE_ID=$(curl -fsSL \
-H "Authorization: token ${TOKEN}" \
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases/tags/${TAG}" | \
grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2)
echo " Release ID: ${RELEASE_ID}"
else
echo "❌ 创建 Release 失败 (HTTP ${HTTP_CODE})"
echo "$RESPONSE_BODY"
exit 1
fi
# 上传文件作为 Release 附件
echo ""
echo "📎 上传文件作为 Release 附件..."
for file in *.tar.gz *.deb; do
[ ! -f "$file" ] && continue
echo " ⬆️ $file"
# 使用 multipart/form-data 上传附件
curl -fsSL -X POST \
-H "Authorization: token ${TOKEN}" \
-F "attachment=@${file}" \
"https://${REGISTRY}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets?name=${file}" || {
echo " ⚠️ 附件上传失败: $file(可能已存在)"
}
done
echo ""
echo "✅ Release 创建完成!"
echo "🔗 访问: https://${REGISTRY}/${{ gitea.repository }}/releases/tag/${TAG}"
# 清理临时文件
rm -f release_body.md
+83
View File
@@ -0,0 +1,83 @@
name: CI
# 分支推送只做校验和原生构建;tag 发布由 release.yml 独立处理。
on:
push:
branches: ["**"]
env:
DOCKER_BUILDKIT: "1"
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
BUILDKIT_PROGRESS: plain
jobs:
validate:
runs-on: ubuntu-latest-amd64
steps:
- uses: actions/checkout@v4
- name: 校验版本、配置和脚本语法
run: |
VERSION=$(tr -d '\r\n' < VERSION)
[[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]
test -s conf/params.example.conf
bash -n debian/build-deb.sh
sh -n init.sh debian/postinst debian/prerm debian/postrm
build:
needs: validate
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest-amd64' || 'ubuntu-latest-arm64' }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- name: 准备原生 Buildx
run: |
BUILDER=$(docker buildx create --use \
--driver docker-container \
--driver-opt network=host \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=50000000 \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000)
echo "BUILDER=${BUILDER}" >> "$GITHUB_ENV"
docker buildx inspect --bootstrap
- name: 构建 ${{ matrix.arch }} 二进制
run: |
VERSION=$(tr -d '\r\n' < VERSION)
docker buildx build --pull \
--platform "linux/${{ matrix.arch }}" \
--build-arg "MONERO_VERSION=v${VERSION}" \
--output type=local,dest=./output \
-f docker/Dockerfile .
- name: 冒烟测试
run: |
DIR="./output/linux_${{ matrix.arch }}"
test -x "${DIR}/mond"
"${DIR}/mond" --version
"${DIR}/mond" --help >/dev/null
LDD_OUT=$(ldd "${DIR}/mond" 2>&1 || true)
grep -qE 'statically linked|not a dynamic executable' <<<"${LDD_OUT}"
- name: 验证 Debian 打包
run: |
VERSION=$(tr -d '\r\n' < VERSION)
TARGZ="mond-${{ matrix.arch }}-linux-static-${VERSION}.tar.gz"
tar -czf "${TARGZ}" -C "./output/linux_${{ matrix.arch }}" .
if ! command -v dpkg-deb >/dev/null; then
sudo apt-get update
sudo apt-get install -y dpkg-dev
fi
./debian/build-deb.sh "${{ matrix.arch }}" "${VERSION}" "${TARGZ}"
DEB="mond_${VERSION}_${{ matrix.arch }}.deb"
CONTENTS=$(dpkg-deb --contents "${DEB}")
grep -Fq 'opt/mond/mond' <<<"${CONTENTS}"
grep -Fq 'opt/mond/params.conf' <<<"${CONTENTS}"
grep -Fq 'lib/systemd/system/mond.service' <<<"${CONTENTS}"
- name: 清理 Buildx
if: always()
run: docker buildx rm "${BUILDER}" || true
+169
View File
@@ -0,0 +1,169 @@
name: Release
on:
push:
tags: ["*"]
env:
DOCKER_BUILDKIT: "1"
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
BUILDKIT_PROGRESS: plain
PRODUCT_NAME: mond
jobs:
build:
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest-amd64' || 'ubuntu-latest-arm64' }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- name: 校验 tag 与源码版本
env:
TAG: ${{ gitea.ref_name }}
run: |
VERSION=$(tr -d '\r\n' < VERSION)
TAG_VERSION="${TAG#v}"
[[ "${TAG_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]
[ "${TAG_VERSION}" = "${VERSION}" ] || {
echo "tag ${TAG_VERSION} 与 VERSION ${VERSION} 不一致"
exit 1
}
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
- name: 准备原生 Buildx
run: |
BUILDER=$(docker buildx create --use \
--driver docker-container \
--driver-opt network=host \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=50000000 \
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=10000000)
echo "BUILDER=${BUILDER}" >> "$GITHUB_ENV"
docker buildx inspect --bootstrap
- name: 构建 ${{ matrix.arch }} 二进制
run: |
docker buildx build --pull \
--platform "linux/${{ matrix.arch }}" \
--build-arg "MONERO_VERSION=v${VERSION}" \
--output type=local,dest=./output \
-f docker/Dockerfile .
- name: 打包并冒烟测试
run: |
DIR="./output/linux_${{ matrix.arch }}"
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${VERSION}.tar.gz"
test -x "${DIR}/mond"
tar -czf "${TARGZ}" -C "${DIR}" .
TEST_DIR=$(mktemp -d)
trap 'rm -rf "${TEST_DIR}"' EXIT
tar -xzf "${TARGZ}" -C "${TEST_DIR}"
"${TEST_DIR}/mond" --version
"${TEST_DIR}/mond" --help >/dev/null
LDD_OUT=$(ldd "${TEST_DIR}/mond" 2>&1 || true)
grep -qE 'statically linked|not a dynamic executable' <<<"${LDD_OUT}"
- name: 构建 Debian 包
run: |
if ! command -v dpkg-deb >/dev/null; then
sudo apt-get update
sudo apt-get install -y dpkg-dev
fi
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${VERSION}.tar.gz"
./debian/build-deb.sh "${{ matrix.arch }}" "${VERSION}" "${TARGZ}"
DEB="${PRODUCT_NAME}_${VERSION}_${{ matrix.arch }}.deb"
CONTENTS=$(dpkg-deb --contents "${DEB}")
grep -Fq 'opt/mond/mond' <<<"${CONTENTS}"
grep -Fq 'opt/mond/params.conf' <<<"${CONTENTS}"
grep -Fq 'lib/systemd/system/mond.service' <<<"${CONTENTS}"
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
with:
name: packages-${{ matrix.arch }}
path: |
*.tar.gz
*.deb
if-no-files-found: error
retention-days: 1
- name: 清理 Buildx
if: always()
run: docker buildx rm "${BUILDER}" || true
release:
needs: build
runs-on: ubuntu-latest-amd64
steps:
- uses: actions/checkout@v4
- uses: https://github.com/ChristopherHX/gitea-download-artifact@v4
with:
pattern: packages-*
path: ./packages
merge-multiple: true
- name: 校验发布文件并生成校验和
env:
TAG: ${{ gitea.ref_name }}
run: |
VERSION=$(tr -d '\r\n' < VERSION)
TAG_VERSION="${TAG#v}"
[ "${TAG_VERSION}" = "${VERSION}" ]
for arch in amd64 arm64; do
test -f "packages/${PRODUCT_NAME}-${arch}-linux-static-${VERSION}.tar.gz"
test -f "packages/${PRODUCT_NAME}_${VERSION}_${arch}.deb"
done
(cd packages && sha256sum *.tar.gz *.deb > SHA256SUMS)
REGISTRY=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "REGISTRY=${REGISTRY}" >> "$GITHUB_ENV"
- name: 上传 Generic 和 Debian 软件包
env:
TOKEN: ${{ secrets.BUILD_TOKEN }}
run: |
OWNER="${{ gitea.repository_owner }}"
for file in packages/*.tar.gz; do
name=$(basename "${file}")
curl -fsSL -X PUT \
-H "Authorization: token ${TOKEN}" \
--upload-file "${file}" \
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/${name}"
done
for file in packages/*.deb; do
curl -fsSL -X PUT \
-H "Authorization: token ${TOKEN}" \
--upload-file "${file}" \
"https://${REGISTRY}/api/packages/${OWNER}/debian/pool/stable/main/upload"
done
- name: 生成 Release 描述
run: |
cat > release-notes.md <<EOF
## Release ${VERSION}
上游版本:[Monero v${VERSION}](https://github.com/monero-project/monero/releases/tag/v${VERSION})
### Debian/Ubuntu 安装
\`\`\`bash
sudo curl https://${REGISTRY}/api/packages/${{ gitea.repository_owner }}/debian/repository.key -o /etc/apt/keyrings/gitea-${{ gitea.repository_owner }}.asc
echo "deb [signed-by=/etc/apt/keyrings/gitea-${{ gitea.repository_owner }}.asc] https://${REGISTRY}/api/packages/${{ gitea.repository_owner }}/debian stable main" | sudo tee /etc/apt/sources.list.d/${{ gitea.repository_owner }}.list
sudo apt-get update && sudo apt-get install mond
\`\`\`
发布附件包含 amd64、arm64 的 tar.gz、Debian 包和 SHA256SUMS。
EOF
- name: 创建或更新 Release 并上传附件
uses: https://gitea.com/actions/gitea-release-action@v1
with:
token: ${{ secrets.BUILD_TOKEN }}
name: Release ${{ gitea.ref_name }}
body_path: release-notes.md
files: |
packages/*.tar.gz
packages/*.deb
packages/SHA256SUMS
+10 -1
View File
@@ -1,7 +1,16 @@
# macOS system files
.DS_Store
# Claude Code
.mcp.json
.claude/
llmdoc/
llmdoc/
example/
.source/
# 构建产物
*.deb
*.tar.gz
output/
packages/
+59
View File
@@ -0,0 +1,59 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## 仓库性质
本仓库**只包含构建与打包基础设施**,不含 mond 源码。源码在编译时从外部仓库克隆(见 [docker/Dockerfile](docker/Dockerfile)):
- 源码仓库:`github.com/monero-project/monero.git`(**Monero 官方仓库**,非换名仓库)
- 发布仓库:Gitea `gitea.bcde.io` 下 `wangdefa/mond` 的 Generic / Debian 包仓库
mond 是 Monero 守护进程 `monerod` 的定制换名构建。换名通过 [init.sh](init.sh) 在编译期对源码做 `sed` 改写完成:`project(monero)→project(mond)`、二进制 `OUTPUT_NAME monerod→mond`、`MONERO_VERSION_*` 宏 → `MOND_VERSION_*`、用户可见字符串 `Monero→Mond`。**改动版本宏或显示字符串相关逻辑时,改 init.sh 而非源码**(源码每次构建都重新克隆)。init.sh 末尾还含 musl 纯静态所需的 CMakeLists patch(见下「为何 patch」)。
> **与同目录 `gitea-xxxig` / `gitea-xxxig-proxy` 的关键差异**:那两个项目源码来自 `wangdefaa`(双 a)换名仓库;mond 直接克隆 Monero 官方仓库,靠 init.sh 现场改名。三者共享同一套 CI / build-deb / debian 打包骨架,且均为 **musl fully-static** 构建;mond 的版本号格式为四段 `0.18.5.1`。
## 整体架构:单二进制
编译产出单个可执行文件 `mond`:Monero 全节点守护进程,负责 P2P 同步区块链、提供 RPC。配置来自 [conf/params.example.conf](conf/params.example.conf)。
## 构建与发布流程(CI)
Gitea Actions 拆成两条独立流水线:
1. [.gitea/workflows/ci.yml](.gitea/workflows/ci.yml) 仅由分支推送触发:先检查版本、配置与 shell 语法,再用 amd64、arm64 原生 runner 并行编译,执行严格冒烟测试并验证 DEB 包内容;不上传 artifact。
2. [.gitea/workflows/release.yml](.gitea/workflows/release.yml) 仅由 tag 推送触发:校验 tag 与 [VERSION](VERSION) 一致,双架构原生构建 → tar.gz → DEB → artifact 汇总 → SHA256SUMS → Generic/Debian Registry → Gitea Release。
关键点:
- **musl fully-static(Alpine 构建,勿改回 glibc)**:[docker/Dockerfile](docker/Dockerfile) 在 `alpine:3.23` 下手动源码编译 5 个静态库(OpenSSL 3.0.21 / libsodium 1.0.20 / libzmq 4.3.5 / expat 2.6.4 / unbound 1.25.1),编出 **static-pie 纯静态**二进制:`ldd` = `statically linked`、零外部依赖,**glibc/musl 任意发行版直接运行**(实测 musl 产物在 Debian 13 上正常运行)。`make daemon` 约 7 分钟/架构(5 库命中 Docker 层缓存后),远快于原 glibc depends 系统的 30–60 分钟。
- **为何用 musl 而非 glibc 全静态**:glibc 的 `getaddrinfo` 依赖运行时 `dlopen` NSS 模块,`-static` 全静态后无法加载 → DNS 解析失败(`DNS error: resource busy or locked`);musl 的 `getaddrinfo` 自带实现,全静态也能正常解析。与 `gitea-xxxig`/`gitea-xxxig-proxy` 一致。曾用的 glibc(ubuntu) depends 构建线已删除。
- **为何 patch monero 源码([init.sh](init.sh) 末尾,勿删)**:monero 官方明确「不支持 fully static」——`CMakeLists.txt` 中 `STATIC=ON` 在 Linux 只加 `-static-libgcc -static-libstdc++`(非真 `-static`),且强制追加 `-pie` 安全加固,会让链接结果带 musl interpreter、退化成动态。故 init.sh 用 `sed` 去掉 `-pie`、把 Linux 的 `STATIC_FLAGS` 改成真 `-static`。Alpine gcc 默认 PIE,`-static` 自动产出 static-pie(零外部依赖)。init.sh 在修改前后都会校验关键锚点,上游结构变化时必须直接失败,不能跳过补丁继续构建。
- **版本号约定**:根目录 [VERSION](VERSION) 是唯一版本来源,内容为不带 `v` 的四段版本号(当前 `0.18.5.1`)。上游 Monero git tag 带 `v`,构建时补回后传给 Dockerfile;tar.gz、DEB 和 Registry 路径使用纯数字版本。发布 tag 可带或不带 `v`,归一后必须与 VERSION 完全一致。
- **依赖精简**:5 个静态库 + libstdc++/libgcc 全部静态链入(真 `-static`),故 [debian/control.template](debian/control.template) **无 `Depends` 字段**(纯静态,连 libc6 都不需要)。
- 架构映射:Dockerfile 内 `arm64→ARCH=armv8-a / BUILD_TAG=linux-armv8`、`amd64→ARCH=x86-64 / BUILD_TAG=linux-x64`(传给 monero cmake);OpenSSL target `aarch64→linux-aarch64`、`x86_64→linux-x86_64`。
- tar.gz 下载 URL 形如 `https://gitea.bcde.io/api/packages/wangdefa/generic/mond/{version}/mond-{arch}-linux-static-{version}.tar.gz`(version 为纯数字)。
## 本地常用命令
```bash
# 本地编译某架构的二进制(输出到 ./output/linux_<arch>/mond)
docker buildx build --platform linux/amd64 \
--build-arg MONERO_VERSION="v$(cat VERSION)" \
--output type=local,dest=./output \
-f docker/Dockerfile .
# 用已有 tar.gz 打 .deb 包(注意第三个参数是 tar.gz,不是目录)
./debian/build-deb.sh amd64 0.18.5.1 mond-amd64-linux-static-0.18.5.1.tar.gz
# 改 shell 脚本后做静态检查(需自行安装 shellcheck)
shellcheck debian/*.sh
```
CI 对二进制执行 `mond --version` 和 `mond --help`,用 `ldd` 严格校验为纯静态,并检查 DEB 内的二进制、默认配置和 systemd 服务。
## Debian 包布局与服务
- 二进制装到 `/opt/mond/mond`,systemd 服务文件 [debian/mond.service](debian/mond.service),维护脚本 `debian/{postinst,prerm,postrm}`。
- **配置流转(单一数据源)**:`conf/params.example.conf` 是唯一配置源 → build-deb.sh 复制进包内 `/opt/mond/params.conf` → postinst 首次安装时 `cp` 到 `/etc/mond/params.conf`(**升级不覆盖**用户已有配置;旧版本位于 `/var/lib/mond/params.conf` 时 postinst 会自动迁移到 `/etc/mond/`)。service 的 `ExecStart` 用 `--config-file=/etc/mond/params.conf`。**改默认配置改 conf/params.example.conf 一处即可**(不要再在 postinst 内联)。
- 数据目录 `/var/lib/mond/data`、日志目录 `/var/log/mond`,均归 `mond` 系统用户。
- postinst 创建 `mond` 系统用户/组。**服务不自动启用/启动**(首次同步需用户确认配置),升级时若服务原为 enabled 则重启以加载新二进制。.deb 安装后手动 `systemctl enable --now mond`。
+74 -214
View File
@@ -1,244 +1,104 @@
# Mond
> Monero daemon 的定制版本
Mond 是 [Monero](https://github.com/monero-project/monero) 守护进程 `monerod` 的定制换名构建——Monero 全节点,负责 P2P 同步区块链、提供 RPC。换名(`monero→mond`、`monerod→mond`、`MONERO_*→MOND_*`)由 [init.sh](init.sh) 在构建期对官方源码做 `sed` 改写完成,不维护源码分叉。
[![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](LICENSE)
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](.gitea/workflows/ci.yaml)
**本仓库只包含构建与打包基础设施**,不含 mond 源码:二进制在 CI 中从上游官方仓库 `github.com/monero-project/monero` 编译(init.sh 现场换名),再打包分发到 [gitea.bcde.io](https://gitea.bcde.io) 的 Generic / Debian 包仓库。
## 🎯 主要特性
## 产物
- 🏗️ **多架构支持** - 原生支持 AMD64 和 ARM64 架构
- 📦 **多种安装方式** - 提供 Debian 包和通用二进制包
- 🐧 **多发行版兼容** - 支持 Ubuntu 和 Debian
- 🔗 **纯静态链接** - 无需依赖,可在任意 Linux 系统运行
- 🔒 **隐私优先** - 基于 Monero 的隐私保护技术
- 🔄 **自动更新** - 通过 Debian 仓库轻松安装和更新
每次构建产出单个可执行文件(musl 纯静态,boost/OpenSSL/libzmq/libsodium/unbound/expat 及 libc 全部静态链入,无外部动态库依赖,任意 Linux 发行版可跑):
## 🚀 快速开始
| 二进制 | 作用 |
|---|---|
| `mond` | Monero 全节点守护进程:P2P 同步区块链、提供 RPC |
### 方式一:Debian/Ubuntu(推荐)
支持架构 `amd64` / `arm64`;musl 纯静态(static-pie),任意 Linux 发行版(Debian/Ubuntu/Alpine/CentOS 等)开箱即跑。
#### Debian 12 (Bookworm)
## 安装
### APT(Debian / Ubuntu)
```bash
# 1. 下载并添加 GPG 密钥
sudo curl https://gitea.bcde.io/api/packages/wangdefa/debian/repository.key \
-o /etc/apt/keyrings/gitea-wangdefa.asc
# 2. 添加软件源
echo "deb [signed-by=/etc/apt/keyrings/gitea-wangdefa.asc] https://gitea.bcde.io/api/packages/wangdefa/debian bookworm main" | \
sudo tee -a /etc/apt/sources.list.d/wangdefa.list
# 3. 安装
sudo apt-get update
sudo apt-get install mond
sudo curl https://gitea.bcde.io/api/packages/wangdefa/debian/repository.key -o /etc/apt/keyrings/gitea-wangdefa.asc
echo "deb [signed-by=/etc/apt/keyrings/gitea-wangdefa.asc] https://gitea.bcde.io/api/packages/wangdefa/debian stable main" | sudo tee /etc/apt/sources.list.d/wangdefa.list
sudo apt-get update && sudo apt-get install mond
```
#### Debian 13 (Trixie)
安装布局:
| | 路径 |
|---|---|
| 二进制 | `/opt/mond/mond` |
| 默认配置 | `/opt/mond/params.conf`(postinst 复制到 `/etc/mond/params.conf`) |
| 数据 | `/var/lib/mond/data` |
| 日志 | `/var/log/mond/` |
| 服务 | `mond.service` |
> 安装后服务**不会自动启动**(首次全节点同步前需确认配置)。按需编辑 `/etc/mond/params.conf`,再启用:
>
> ```bash
> sudo systemctl enable --now mond
> ```
### tar.gz(通用:Alpine / Ubuntu / Debian)
从 Generic Package Registry 下载对应架构的 tar.gz,解压即用(单二进制):
```bash
# 1. 下载并添加 GPG 密钥
sudo curl https://gitea.bcde.io/api/packages/wangdefa/debian/repository.key \
-o /etc/apt/keyrings/gitea-wangdefa.asc
# 2. 添加软件源
echo "deb [signed-by=/etc/apt/keyrings/gitea-wangdefa.asc] https://gitea.bcde.io/api/packages/wangdefa/debian trixie main" | \
sudo tee -a /etc/apt/sources.list.d/wangdefa.list
# 3. 安装
sudo apt-get update
sudo apt-get install mond
curl -fSL -o mond.tar.gz \
https://gitea.bcde.io/api/packages/wangdefa/generic/mond/0.18.5.1/mond-amd64-linux-static-0.18.5.1.tar.gz
tar -xzf mond.tar.gz
./mond --config-file params.conf # 配置模板见仓库 conf/params.example.conf
```
### 方式二:通用二进制包
## 构建与发布
Gitea Actions 分为两条流水线:
- [.gitea/workflows/ci.yml](.gitea/workflows/ci.yml):分支推送时检查版本、配置和 shell 语法,并在 amd64、arm64 原生 runner 上编译、严格冒烟测试和验证 DEB 包内容。
- [.gitea/workflows/release.yml](.gitea/workflows/release.yml):tag 推送时构建 tar.gz 和 DEB,生成 `SHA256SUMS`,上传包仓库并创建或更新 Release。
musl 纯静态在 `alpine:3.23` 下手编 5 个静态库(OpenSSL 3.0.21、libsodium 1.0.20、libzmq 4.3.5、expat 2.6.4、unbound 1.25.1)并 patch monero CMakeLists(去 `-pie`、Linux `STATIC_FLAGS` 改真 `-static`),产出 static-pie 零依赖二进制。换名 + patch 逻辑见 [init.sh](init.sh)。
本地构建:
```bash
# 1. 下载对应架构的包
wget https://gitea.bcde.io/releases/download/VERSION/mond-amd64-ubuntu-VERSION.tar.gz
# 2. 解压
tar -xzf mond-amd64-ubuntu-VERSION.tar.gz
# 3. 运行
./mond --help
```
## 📋 使用说明
### Debian/Ubuntu 系统服务
#### 启动服务
```bash
# 启用并启动服务
sudo systemctl enable mond.service
sudo systemctl start mond.service
# 查看状态
sudo systemctl status mond.service
# 查看日志
sudo journalctl -u mond -f
```
#### 停止服务
```bash
sudo systemctl stop mond.service
sudo systemctl disable mond.service
```
### 直接运行
```bash
# 基本运行
./mond
# 指定数据目录
./mond --data-dir=/path/to/data
# 指定日志文件
./mond --log-file=/path/to/log
# 后台运行
./mond --detach
```
## ⚙️ 配置说明
### 目录结构
#### Debian/Ubuntu 系统包
```
/opt/mond/mond # 二进制文件
/var/lib/mond/ # 区块链数据目录
/var/log/mond/ # 日志目录
```
#### 通用二进制包
```
./mond # 二进制文件
```
### 常用命令行选项
```bash
--data-dir <path> # 指定数据目录
--log-file <path> # 指定日志文件路径
--log-level <level> # 日志级别 (0-4)
--detach # 后台运行
--rpc-bind-ip <ip> # RPC 绑定 IP (默认: 127.0.0.1)
--rpc-bind-port <port> # RPC 绑定端口 (默认: 18081)
--p2p-bind-ip <ip> # P2P 绑定 IP (默认: 0.0.0.0)
--p2p-bind-port <port> # P2P 绑定端口 (默认: 18080)
```
## 🔄 修改内容
本项目基于 [Monero](https://github.com/monero-project/monero) 进行以下修改:
1. **项目重命名**:`monero` → `mond`
2. **二进制文件名**:`monerod` → `mond`
3. **版本标识**:`MONERO_*` → `MOND_*`
所有修改通过 [init.sh](init.sh) 在构建过程中自动应用。
## 🏗️ 构建说明
### Docker 构建(推荐)
本项目使用 Docker 和官方 depends 系统构建,确保纯静态链接。
#### 构建多架构二进制文件
```bash
# 构建 amd64 和 arm64 架构
docker buildx build --platform linux/amd64,linux/arm64 \
-f docker/Dockerfile.ubuntu \
--output type=local,dest=./output .
```
#### 构建单一架构
```bash
# 仅构建 amd64
# 编译某架构二进制(输出到 ./output/linux_<arch>/mond)
docker buildx build --platform linux/amd64 \
-f docker/Dockerfile.ubuntu \
--output type=local,dest=./output .
--build-arg MONERO_VERSION="v$(cat VERSION)" \
--output type=local,dest=./output \
-f docker/Dockerfile .
# 仅构建 arm64
docker buildx build --platform linux/arm64 \
-f docker/Dockerfile.ubuntu \
--output type=local,dest=./output .
```
#### 验证静态链接
```bash
# 检查二进制文件是否为纯静态链接
# 校验纯静态(应输出 "statically linked")
ldd output/linux_amd64/mond
# 预期输出: "not a dynamic executable"
file output/linux_amd64/mond
# 预期输出: "statically linked"
# 用产物 tar.gz 打 .deb
./debian/build-deb.sh amd64 0.18.5.1 mond-amd64-linux-static-0.18.5.1.tar.gz
```
### 本地构建
## 版本号约定
如果不使用 Docker,可以手动构建:
- 根目录 [VERSION](VERSION) 是唯一版本来源,使用不带 `v` 的四段版本号。
- **上游源码 git tag** 带 `v`(如 `v0.18.5.1`),CI 构建时自动补回。
- **包版本**(tar.gz / deb / registry 路径)一律用数字(如 `0.18.5.1`),符合 Debian 版本规范。
- 发布 tag 可写成 `0.18.5.1` 或 `v0.18.5.1`,去掉 `v` 后必须与 VERSION 一致。
```bash
# 1. 克隆并准备源代码
git clone https://github.com/monero-project/monero.git .source
cd .source
git checkout v0.18.3.4
git submodule update --init --force
发版时先更新 VERSION 并提交,再创建同版本 tag。
# 2. 应用修改
../init.sh
## 修改内容
# 3. 使用 depends 系统构建(推荐)
make -j$(nproc) depends target=x86_64-linux-gnu
# 二进制文件位于: build/x86_64-linux-gnu/release/bin/mond
基于 [Monero](https://github.com/monero-project/monero)(BSD-3-Clause),由 [init.sh](init.sh) 在构建期自动应用,不维护源码分叉:
- 项目名 `monero` → `mond`
- 二进制 `monerod` → `mond`
- 版本宏 `MONERO_*` → `MOND_*`
## 目录结构
# 或者简单构建(需要手动安装依赖)
mkdir -p build/release && cd build/release
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI_DEPS=OFF
make -j$(nproc) daemon
```
### 构建环境要求
- **操作系统**: Ubuntu 20.04(推荐)或更新版本
- **CPU**: 多核 CPU(构建时间约 30-60 分钟)
- **内存**: 至少 4GB RAM
- **磁盘**: 至少 10GB 可用空间
- **Docker**: 如使用 Docker 构建,需安装 Docker 和 buildx
## 📝 许可证
本项目基于 BSD-3-Clause 许可证开源。
- 原始项目:[Monero](https://github.com/monero-project/monero) (BSD-3-Clause)
- 修改内容:详见 [init.sh](init.sh)
## 🙏 致谢
- [Monero Project](https://github.com/monero-project/monero) - 原始项目和核心技术
## ⚠️ 免责声明
本软件仅供学习和研究使用。使用本软件进行任何活动请遵守当地法律法规。作者不对使用本软件造成的任何损失或法律问题负责。
## 📞 支持
如有问题或建议,请通过以下方式联系:
- 提交 Issue
- 发送 Pull Request
---
**注意**:本项目是 Monero 的定制版本,不代表官方 Monero 项目。
.gitea/workflows/ CI 流水线
docker/ Dockerfile(musl 纯静态,从上游官方源码编译 + init.sh 换名)
debian/ .deb 打包:control 模板、维护脚本、systemd 服务
conf/ params.example.conf 默认配置模板
init.sh 构建期换名 + 静态 patch 脚本
```
+1
View File
@@ -0,0 +1 @@
0.18.5.1
+388
View File
@@ -0,0 +1,388 @@
# Mond Configuration File
# ============================================================================
# This file is automatically created during installation
# Edit this file to customize your Mond daemon settings
# After modifying, restart the service: sudo systemctl restart mond.service
# ============================================================================
# DATA STORAGE
# ============================================================================
# data-dir: 区块链数据存储目录
# - 包含完整的区块链数据、交易池和节点状态
# - 确保该目录所在磁盘有足够空间(完整节点需要 150GB+,修剪节点需要 50GB+)
# - 默认位置: ~/.bitmonero (用户安装) 或 /var/lib/mond (系统服务)
data-dir=/var/lib/mond/data
# BLOCKCHAIN PRUNING
# ============================================================================
# prune-blockchain: 启用区块链修剪模式
# - 1 = 启用修剪,只保留最近的区块数据和必要的历史信息
# - 0 = 禁用修剪,保留完整的区块链历史(默认)
# - 优点: 大幅减少磁盘使用(从 150GB+ 降至 50GB 左右)
# - 缺点: 无法向其他节点提供完整的历史区块数据
# - 注意: 修剪节点仍然可以完全验证区块链,只是不存储所有旧数据
prune-blockchain=1
# sync-pruned-blocks: 同步修剪后的区块
# - 1 = 允许从其他修剪节点同步数据(推荐)
# - 0 = 仅从完整节点同步
# - 建议与 prune-blockchain=1 一起使用,加速初始同步
sync-pruned-blocks=1
# ZMQ NOTIFICATION SYSTEM
# ============================================================================
# zmq-pub: ZeroMQ 发布接口,用于实时广播区块链事件
# - tcp://IP:PORT 格式指定绑定地址和端口
# - 127.0.0.1 = 仅本地访问(推荐,除非需要远程订阅)
# - 18083 = 默认 ZMQ 端口(可修改)
# - 用途: P2Pool 挖矿、实时监控工具、区块浏览器等
# - 发布的事件类型:
# * json-full-chain_main: 新区块添加到主链
# * json-full-txpool_add: 新交易进入交易池
# * json-minimal-chain_main: 简化的新区块信息
# * json-minimal-txpool_add: 简化的新交易信息
# - 如需外部访问,改为 tcp://0.0.0.0:18083 并添加 confirm-external-bind=1
zmq-pub=tcp://127.0.0.1:18083
# NETWORK PEER SETTINGS
# ============================================================================
# out-peers: 主动连接的对等节点数量(出站连接)
# - 默认: 8,这里设置为 32 可提高网络连接性和同步速度
# - 范围: 0-1000,推荐值: 8-64
# - 更多出站连接 = 更快的区块传播,但消耗更多带宽和资源
out-peers=32
# in-peers: 接受连接的对等节点数量(入站连接)
# - 默认: 无限制,这里设置为 64 可平衡网络贡献和资源消耗
# - 范围: 0-无限,推荐值: 32-128
# - 入站连接有助于网络去中心化,但需要开放 P2P 端口(18080)
in-peers=64
# limit-rate-up: 上传速率限制(kB/s,千字节/秒)
# - 1024 kB/s = 1 MB/s = 8 Mbps
# - 默认: 8192 kB/s = 8 MB/s = 64 Mbps
# - -1 = 无限制(不推荐,可能耗尽带宽)
# - 根据网络带宽调整,建议保留部分带宽给其他应用
# - 计算公式: (总上传带宽 Mbps * 1024) / 8 = kB/s
# - 示例:
# * 10 Mbps 上传 → limit-rate-up=1280 (10 * 1024 / 8)
# * 50 Mbps 上传 → limit-rate-up=6400 (50 * 1024 / 8)
# * 100 Mbps 上传 → limit-rate-up=12800 (100 * 1024 / 8)
limit-rate-up=1048576
# limit-rate-down: 下载速率限制(kB/s,千字节/秒)
# - 1024 kB/s = 1 MB/s = 8 Mbps
# - 默认: 32768 kB/s = 32 MB/s = 256 Mbps
# - -1 = 无限制(初始同步时推荐)
# - 同步完成后可设置限制,节省带宽
# - 注意: 限制过低会影响区块同步速度
# - 示例:
# * 50 Mbps 下载 → limit-rate-down=6400 (50 * 1024 / 8)
# * 100 Mbps 下载 → limit-rate-down=12800 (100 * 1024 / 8)
# * 无限制(推荐初始同步)→ limit-rate-down=-1
limit-rate-down=1048576
# PRIORITY NODES
# ============================================================================
# add-priority-node: 优先连接的可信节点
# - 格式: 域名:端口 或 IP:端口
# - 节点会优先与这些节点建立连接并保持连接
# - 用途:
# * 加速初始同步(连接到高速节点)
# * 提高网络可靠性(连接到稳定节点)
# * 优先从可信来源获取区块
# - 可以添加多个优先节点(重复使用此选项)
# - 这些节点必须开放 P2P 端口(通常是 18080)
add-priority-node=p2pmd.xmrvsbeast.com:18080
add-priority-node=nodes.hashvault.pro:18080
# 可以添加更多优先节点:
# add-priority-node=node.supportxmr.com:18080
# add-priority-node=node.moneroworld.com:18080
# add-priority-node=opennode.xmr-tw.org:18080
# SECURITY AND NETWORK INTEGRITY
# ============================================================================
# enforce-dns-checkpointing: 强制执行 DNS 检查点验证
# - 1 = 启用(推荐),通过 DNS TXT 记录验证区块链检查点
# - 0 = 禁用
# - 作用: 防止长期离线后被恶意分叉欺骗
# - DNS 检查点由 Monero 核心开发者维护
# - 安全增强措施,几乎没有缺点
enforce-dns-checkpointing=1
# enable-dns-blocklist: 启用 DNS 黑名单
# - 1 = 启用(推荐),阻止连接到已知的恶意节点
# - 0 = 禁用
# - 黑名单通过 DNS 记录维护,包含:
# * Sybil 攻击节点
# * 已知的恶意节点
# * 降低网络性能的节点
# - 提高网络安全性和连接质量
enable-dns-blocklist=1
# P2P AND RPC NETWORK BINDING
# ============================================================================
# 以下配置控制节点的网络接口绑定
# 默认全部注释掉(使用内置默认值)
# 根据使用场景取消注释并修改
# --- P2P 绑定设置 ---
# p2p-bind-ip: P2P 网络监听地址
# - 0.0.0.0 = 监听所有网络接口(公网+内网+本地)
# - 127.0.0.1 = 仅本地访问(不接受外部节点连接)
# - 192.168.x.x = 仅内网访问
# - 默认: 0.0.0.0(接受所有连接)
# 使用场景:
# * 公共节点: 0.0.0.0(贡献网络,需开放防火墙 18080 端口)
# * 私有节点: 127.0.0.1(不接受入站连接,仅主动连接其他节点)
#p2p-bind-ip=0.0.0.0
# p2p-bind-port: P2P 网络监听端口
# - 18080 = 主网默认端口
# - 28080 = 测试网 (testnet) 端口
# - 38080 = 预发布网 (stagenet) 端口
# - 使用非标准端口可以减少扫描攻击,但会降低网络发现性
#p2p-bind-port=18080
# --- RPC 绑定设置 ---
# rpc-bind-ip: RPC 接口监听地址
# - 0.0.0.0 = 监听所有网络接口(危险!需要配合认证和 SSL)
# - 127.0.0.1 = 仅本地访问(推荐,安全)
# - 192.168.x.x = 仅内网访问
# - 默认: 127.0.0.1(仅本地)
# ⚠️ 安全警告:
# * RPC 端口有完整控制权限,暴露到公网极度危险!
# * 如果必须远程访问,必须配置:
# 1. rpc-login (用户名密码)
# 2. rpc-ssl (SSL/TLS 加密)
# 3. 防火墙规则(限制访问 IP)
# * 推荐使用 SSH 隧道代替直接暴露
#rpc-bind-ip=0.0.0.0
# rpc-bind-port: RPC 接口监听端口
# - 18081 = 主网默认 RPC 端口
# - 28081 = 测试网 RPC 端口
# - 38081 = 预发布网 RPC 端口
# - 用于本地钱包、P2Pool、管理工具连接
#rpc-bind-port=18081
# --- 公共受限 RPC (推荐用于公共服务) ---
# rpc-restricted-bind-ip: 受限 RPC 监听地址
# - 仅提供只读 API,不能发送交易或控制节点
# - 可以安全绑定到 0.0.0.0 提供公共查询服务
# - 不返回隐私敏感数据
# 使用场景: 公共区块浏览器、轻钱包后端、查询服务
#rpc-restricted-bind-ip=0.0.0.0
# rpc-restricted-bind-port: 受限 RPC 监听端口
# - 推荐使用与标准 RPC 不同的端口(如 18089)
# - 可以与标准 RPC 同时运行
#rpc-restricted-bind-port=18089
# --- 启用受限 RPC 模式 ---
# restricted-rpc: 将绑定的 RPC 端口设为受限模式
# - 必须与 rpc-restricted-bind-port 配合使用
# - 限制可用的 RPC 方法,禁止敏感操作
#restricted-rpc=1
# confirm-external-bind: 确认外部网络绑定
# - 1 = 明确确认将服务绑定到非本地地址
# - 安全措施: 防止误将服务暴露到公网
# - 当使用 0.0.0.0 或非 127.0.0.1 地址时必须添加此选项
# - 适用于: p2p-bind-ip, rpc-bind-ip, rpc-restricted-bind-ip, zmq-pub
#confirm-external-bind=1
# RPC AUTHENTICATION
# ============================================================================
# rpc-login: RPC 访问认证凭据
# - 格式: username:password
# - ⚠️ 强制要求: 当 rpc-bind-ip 不是 127.0.0.1 时必须配置
# - 密码要求:
# * 至少 16 字符
# * 包含大小写字母、数字、特殊字符
# * 避免使用字典词汇
# - 生成强密码命令:
# openssl rand -base64 32
# pwgen -s 32 1
# - 示例: rpc-login=admin:xK9mP2vL8qR5nW7jT3hY6fB4sD1gA0cE
# - 客户端连接示例:
# curl -u admin:password http://127.0.0.1:18081/json_rpc
# mond-wallet-cli --daemon-address admin:password@node.example.com:18081
#rpc-login=user:password
# RPC SSL/TLS ENCRYPTION
# ============================================================================
# rpc-ssl: 启用 RPC 连接的 SSL/TLS 加密
# - enabled = 强制使用 SSL(推荐用于远程访问)
# - disabled = 禁用 SSL(仅本地访问时可用)
# - autodetect = 自动检测客户端支持情况(默认)
# - ⚠️ 远程访问必须启用 SSL,否则密码明文传输!
# - 需要配合 rpc-ssl-certificate 和 rpc-ssl-private-key
#rpc-ssl=enabled
# rpc-ssl-certificate: SSL 证书文件路径
# - PEM 格式的 SSL/TLS 证书
# - 可以使用自签名证书或由 CA 签发的证书
# - 生成自签名证书(仅用于测试):
# openssl req -newkey rsa:4096 -nodes -keyout key.pem \
# -x509 -days 365 -out cert.pem
# - 生产环境推荐使用 Let's Encrypt 免费证书:
# certbot certonly --standalone -d your-node.example.com
# - Let's Encrypt 证书路径:
# /etc/letsencrypt/live/your-domain/fullchain.pem
#rpc-ssl-certificate=/path/to/your/certificate.pem
# rpc-ssl-private-key: SSL 私钥文件路径
# - PEM 格式的私钥文件
# - ⚠️ 安全要求:
# * 文件权限必须是 600 (chmod 600 key.pem)
# * 所有者必须是运行 mond 的用户
# * 不要将私钥文件暴露到公共位置
# - Let's Encrypt 私钥路径:
# /etc/letsencrypt/live/your-domain/privkey.pem
#rpc-ssl-private-key=/path/to/your/private_key.pem
# rpc-ssl-ca-certificates: CA 证书路径(可选)
# - 用于验证客户端证书(双向 SSL)
# - 大多数情况下不需要
#rpc-ssl-ca-certificates=/path/to/ca-bundle.pem
# rpc-ssl-allow-any-cert: 允许任何证书(不推荐)
# - 1 = 禁用客户端证书验证
# - 0 = 验证客户端证书(默认)
# - ⚠️ 仅用于测试,生产环境不要启用
#rpc-ssl-allow-any-cert=0
# rpc-access-control-origins: CORS 跨域访问控制(可选)
# - 允许从特定域名的 Web 应用访问 RPC
# - 格式: http://domain.com 或多个域名用逗号分隔
# - 用于 Web 钱包、区块浏览器等前端应用
# - 示例: https://wallet.example.com,https://explorer.example.com
# - 使用 * 允许所有域名(不推荐)
#rpc-access-control-origins=https://your-domain.com
# LOGGING SETTINGS
# ============================================================================
# log-level: 日志详细程度
# - 0 = 最小化日志(仅关键错误)
# - 1 = 错误级别(推荐用于生产环境)
# - 2 = 警告级别(包含潜在问题)
# - 3 = 信息级别(当前设置,常规操作信息)
# - 4 = 调试级别(详细的调试信息,仅用于故障排查)
# - 更高级别 = 更多日志输出,但也消耗更多磁盘 I/O
# - 建议:
# * 生产环境: 1 或 2
# * 开发/调试: 3 或 4
# * 初始同步: 3(监控同步进度)
log-level=3
# log-file: 日志文件保存路径
# - 所有日志输出将写入此文件
# - 确保目录存在且有写入权限
# - 文件会自动轮转(达到一定大小后创建新文件)
# - 查看日志命令:
# tail -f /var/log/mond/mond.log (实时查看)
# grep ERROR /var/log/mond/mond.log (搜索错误)
# - 日志管理:
# * 定期清理旧日志释放磁盘空间
# * 可配合 logrotate 自动管理
# * 推荐保留最近 7-30 天的日志
log-file=/var/log/mond/mond.log
# max-log-file-size: 单个日志文件最大大小(字节)
# - 达到此大小后自动创建新日志文件
# - 默认: 104850000 (约 100 MB)
# - 推荐值: 10485760 (10 MB) 到 104857600 (100 MB)
# - 示例: max-log-file-size=52428800 # 50 MB
#max-log-file-size=104850000
# max-log-files: 保留的日志文件数量
# - 超过此数量后删除最旧的日志文件
# - 默认: 50
# - 计算存储空间: max-log-file-size * max-log-files
# - 示例: 如果单文件 50MB,保留 20 个文件 = 1GB 空间
#max-log-files=50
# ADVANCED OPTIONS (COMMENTED OUT)
# ============================================================================
# 以下是一些高级选项,默认不启用,根据需求取消注释
# --- 数据库设置 ---
# db-sync-mode: 数据库同步模式
# - fast:async:250000000bytes = 快速异步模式(默认,推荐)
# - fast:sync = 快速同步模式(更安全但稍慢)
# - fastest:async:250000000bytes = 最快模式(性能优先)
# - safe = 最安全模式(每次写入都刷盘,非常慢)
# 影响: 同步速度 vs 断电时的数据完整性
#db-sync-mode=fast:async:250000000bytes
# --- 区块同步设置 ---
# block-sync-size: 每次同步请求的区块数量
# - 默认: 20
# - 范围: 1-100,更大的值可能加快同步但消耗更多内存
#block-sync-size=20
# prep-blocks-threads: 预处理区块的线程数
# - 默认: 4
# - 根据 CPU 核心数调整,建议为核心数的 50-100%
#prep-blocks-threads=4
# --- 带宽和连接设置 ---
# max-txpool-weight: 交易池最大权重(字节)
# - 默认: 648000000 (约 618 MB)
# - 限制内存中未确认交易的总大小
#max-txpool-weight=648000000
# pad-transactions: 填充交易大小(隐私增强)
# - 1 = 启用,将交易填充到标准大小
# - 0 = 禁用(默认)
# - 增强隐私但增加交易费用
#pad-transactions=0
# --- 挖矿设置 ---
# start-mining: 启动时开始挖矿
# - 格式: 钱包地址
# - 不推荐在 mond 直接挖矿,应使用专用挖矿软件或 P2Pool
#start-mining=YOUR_WALLET_ADDRESS
# mining-threads: 挖矿线程数
# - 仅在 start-mining 启用时有效
# - 推荐: CPU 核心数的 50-75%
#mining-threads=2
# --- 匿名网络支持 ---
# tx-proxy: 通过代理发送交易(增强隐私)
# - 格式: socks4a://IP:PORT 或 i2p://address
# - 用于通过 Tor/I2P 广播交易
# - 示例(Tor): tx-proxy=socks4a://127.0.0.1:9050
#tx-proxy=socks4a://127.0.0.1:9050
# anonymous-inbound: 匿名网络入站地址
# - 格式: address,port[,max_connections]
# - 允许通过 Tor/I2P 接收连接
# - 示例: anonymous-inbound=your_onion_address.onion:18083,127.0.0.1:18083,25
#anonymous-inbound=your_address.onion:18083,127.0.0.1:18083
# --- 性能优化 ---
# max-concurrency: 最大并发线程数
# - 默认: 0(自动检测 CPU 核心数)
# - 手动设置可限制 CPU 使用
#max-concurrency=0
# db-salvage: 尝试修复损坏的数据库
# - 1 = 启动时检查并修复
# - 0 = 不自动修复(默认)
# - 仅在数据库损坏时使用
#db-salvage=0
# --- 网络类型 ---
# testnet: 使用测试网络
# - 1 = 启用测试网(用于开发测试)
# - 0 = 使用主网(默认)
#testnet=0
# stagenet: 使用预发布网络
# - 1 = 启用预发布网(开发者测试环境)
# - 0 = 使用主网(默认)
#stagenet=0
+20 -17
View File
@@ -3,16 +3,18 @@ set -e
# 参数检查
if [ $# -ne 3 ]; then
echo "Usage: $0 <ARCH> <VERSION> <BINARY_DIR>"
echo "Example: $0 amd64 0.18.4.4 build/Linux/release/bin"
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
echo "Example: $0 amd64 0.18.5.1 mond-amd64-linux-static-0.18.5.1.tar.gz"
exit 1
fi
ARCH=$1
VERSION=$2
BINARY_DIR=$3
TARGZ_FILE=$3
PKG_NAME="mond"
DEB_FILE="${PKG_NAME}_${VERSION}_${ARCH}.deb"
DEB_VERSION="${VERSION#v}" # Debian 版本号必须以数字开头,去掉可能的 v 前缀
[ -f "$TARGZ_FILE" ] || { echo "❌ 找不到产物包: $TARGZ_FILE"; exit 1; }
# 转换架构名称(Docker 使用的架构名到 Debian 架构名)
case "$ARCH" in
@@ -28,34 +30,34 @@ case "$ARCH" in
;;
esac
DEB_FILE="${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}.deb"
echo "📦 Building Debian package: ${DEB_FILE}"
echo " Architecture: ${DEB_ARCH}"
echo " Version: ${VERSION}"
echo " Binary directory: ${BINARY_DIR}"
# 检查二进制文件是否存在
if [ ! -f "${BINARY_DIR}/mond" ]; then
echo "❌ Error: mond binary not found in ${BINARY_DIR}"
exit 1
fi
echo " Version: ${DEB_VERSION}"
echo " Source: ${TARGZ_FILE}"
# 创建临时目录
BUILD_DIR=$(mktemp -d)
trap "rm -rf $BUILD_DIR" EXIT
# 创建包目录结构
PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${VERSION}_${DEB_ARCH}"
PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}"
mkdir -p "${PKG_DIR}/DEBIAN"
mkdir -p "${PKG_DIR}/opt/mond"
mkdir -p "${PKG_DIR}/lib/systemd/system"
# 复制二进制文件
echo "📂 Copying binary..."
cp "${BINARY_DIR}/mond" "${PKG_DIR}/opt/mond/mond"
# 解压二进制文件
echo "📂 Extracting binary..."
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/mond"
# 打入默认配置(conf/params.example.conf 为唯一配置源,postinst 据此生成 /etc/mond/params.conf)
echo "📄 Bundling default config..."
cp conf/params.example.conf "${PKG_DIR}/opt/mond/params.conf"
# 生成 control 文件
echo "📝 Generating control file..."
sed -e "s/{{VERSION}}/${VERSION}/" \
sed -e "s/{{VERSION}}/${DEB_VERSION}/" \
-e "s/{{ARCH}}/${DEB_ARCH}/" \
debian/control.template > "${PKG_DIR}/DEBIAN/control"
@@ -74,6 +76,7 @@ cp debian/mond.service "${PKG_DIR}/lib/systemd/system/"
# 设置权限
chmod 755 "${PKG_DIR}/opt/mond/mond"
chmod 644 "${PKG_DIR}/opt/mond/params.conf"
chmod 644 "${PKG_DIR}/lib/systemd/system/mond.service"
# 构建 deb 包
-1
View File
@@ -3,7 +3,6 @@ Version: {{VERSION}}
Section: net
Priority: optional
Architecture: {{ARCH}}
Depends: libc6, libboost-system1.74.0 | libboost-system1.81.0 | libboost-system1.83.0, libboost-filesystem1.74.0 | libboost-filesystem1.81.0 | libboost-filesystem1.83.0, libboost-thread1.74.0 | libboost-thread1.81.0 | libboost-thread1.83.0, libboost-program-options1.74.0 | libboost-program-options1.81.0 | libboost-program-options1.83.0, libssl3 | libssl1.1, libzmq5, libunwind8
Maintainer: Mond Team <noreply@example.com>
Homepage: https://github.com/monero-project/monero
Description: Mond cryptocurrency daemon
+2 -2
View File
@@ -8,8 +8,8 @@ Type=simple
# 工作目录
WorkingDirectory=/opt/mond
# 执行命令
ExecStart=/opt/mond/mond --data-dir=/var/lib/mond --log-file=/var/log/mond/mond.log --detach
# 执行命令 - 使用配置文件
ExecStart=/opt/mond/mond --config-file=/etc/mond/params.conf --non-interactive
# 重启策略
Restart=always
+37 -23
View File
@@ -17,21 +17,43 @@ mkdir -p /var/log/mond
chown mond:mond /var/log/mond
chmod 750 /var/log/mond
# Create data directory
mkdir -p /var/lib/mond
chown mond:mond /var/lib/mond
chmod 750 /var/lib/mond
# Create data directory(非递归设权限,避免升级时遍历庞大的区块链数据目录)
mkdir -p /var/lib/mond/data
chown mond:mond /var/lib/mond /var/lib/mond/data
chmod 750 /var/lib/mond /var/lib/mond/data
# Set permissions on binary
chown root:mond /opt/mond/mond
# Create config directory
mkdir -p /etc/mond
# 兼容旧版本:配置文件曾位于 /var/lib/mond/params.conf,迁移到 /etc/mond/params.conf
if [ ! -f /etc/mond/params.conf ] && [ -f /var/lib/mond/params.conf ]; then
echo "Migrating existing config from /var/lib/mond to /etc/mond..."
cp /var/lib/mond/params.conf /etc/mond/params.conf
fi
# 首次安装:从包内默认配置生成(源:conf/params.example.conf)。升级不覆盖已有配置
if [ ! -f /etc/mond/params.conf ]; then
cp /opt/mond/params.conf /etc/mond/params.conf
fi
chown mond:mond /etc/mond/params.conf
chmod 640 /etc/mond/params.conf
# Set permissions:/opt 目录与二进制 755,数据文件 644(对齐 xxxig / xxxig-proxy)
chown -R root:root /opt/mond
find /opt/mond -type d -exec chmod 755 {} +
find /opt/mond -type f -exec chmod 644 {} +
chmod 755 /opt/mond/mond
# Reload systemd
if [ -d /run/systemd/system ]; then
systemctl daemon-reload
# Note: Service is NOT auto-enabled or auto-started
# Users should manually enable the service:
# 升级时重启正在运行的服务以加载新二进制;try-restart 不会启动未运行的服务,
# 故首次安装仍保持"不自动启动"语义
systemctl try-restart mond.service 2>/dev/null || true
# Note: On fresh install, service is NOT auto-enabled or auto-started
# systemctl enable mond.service
# systemctl start mond.service
fi
@@ -39,22 +61,14 @@ fi
echo ""
echo "✅ Mond installed successfully!"
echo ""
echo "📋 Service Information:"
echo "📁 Important paths:"
echo " Config file: /etc/mond/params.conf"
echo " Data directory: /var/lib/mond/data"
echo " Log directory: /var/log/mond"
echo " Binaries: /opt/mond/mond"
echo " Systemd services: mond.service"
echo ""
echo " mond - Mond cryptocurrency network daemon"
echo ""
echo "To start the daemon:"
echo " sudo systemctl enable mond.service"
echo " sudo systemctl start mond.service"
echo ""
echo "Data directory:"
echo " /var/lib/mond"
echo ""
echo "Log directory:"
echo " /var/log/mond"
echo ""
echo "Binary location:"
echo " /opt/mond/mond"
echo "💡 Tip: Your config files will NOT be overwritten during package upgrades."
echo ""
exit 0
+3 -9
View File
@@ -12,16 +12,10 @@ case "$1" in
delgroup --quiet mond || true
fi
# Remove log directory
# Remove data/config directories (only on purge)
rm -rf /var/log/mond
# Note: We keep /var/lib/mond (blockchain data) for safety
# Users can manually remove it if needed
echo ""
echo "⚠️ Blockchain data preserved at: /var/lib/mond"
echo "To completely remove all data, run:"
echo " sudo rm -rf /var/lib/mond"
echo ""
rm -rf /var/lib/mond
rm -rf /etc/mond
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+3 -2
View File
@@ -1,8 +1,9 @@
#!/bin/sh
set -e
# Stop and disable service if running
if [ -d /run/systemd/system ]; then
# 仅在卸载(remove)时停用服务;升级(upgrade)时保持运行,
# 由 postinst 的 try-restart 重启以加载新二进制
if [ "$1" = "remove" ] && [ -d /run/systemd/system ]; then
if systemctl is-active --quiet mond.service; then
echo "Stopping mond service..."
systemctl stop mond.service
+66
View File
@@ -0,0 +1,66 @@
# musl fully-static 构建 mond(monerod 换名):手编 5 个静态库 + patch CMakeLists + static-pie。
# 为何 musl 而非 glibc:musl 的 getaddrinfo 自包含,全静态可跨发行版运行;glibc 静态会因 NSS
# 运行时 dlopen 失败(DNS error: resource busy or locked)。详见 CLAUDE.md。
# 产物为 static-pie(Alpine gcc 默认 PIE),零外部依赖,可在 glibc/musl 任意发行版直接运行。
# ---- Stage 1: 静态依赖库(版本固定 → Docker 层缓存,源码不变不重编)----
FROM alpine:3.23 AS deps
RUN apk add --no-cache g++ gcc make cmake git linux-headers autoconf automake libtool \
pkgconf perl wget tar xz bzip2 file flex bison boost-static boost-dev rapidjson-dev
ENV CFLAGS="-fPIC -O2" CXXFLAGS="-fPIC -O2"
WORKDIR /deps
# OpenSSL 3.0.21(与 Monero v0.18.5.1 depends 对齐;Alpine 仓库只有 .so,须源码编静态)
RUN wget -q https://github.com/openssl/openssl/releases/download/openssl-3.0.21/openssl-3.0.21.tar.gz && \
tar xf openssl-3.0.21.tar.gz && cd openssl-3.0.21 && \
if [ "$(uname -m)" = aarch64 ]; then OSSL_T=linux-aarch64; else OSSL_T=linux-x86_64; fi && \
./Configure no-shared no-tests --prefix=/usr --libdir=lib $OSSL_T && \
make -j"$(nproc)" && make install_sw && cd / && rm -rf /deps/openssl-3.0.21*
# libsodium 1.0.20
RUN wget -q https://download.libsodium.org/libsodium/releases/libsodium-1.0.20.tar.gz && \
tar xf libsodium-1.0.20.tar.gz && cd libsodium-1.0.20 && \
./configure --enable-static --disable-shared --prefix=/usr && \
make -j"$(nproc)" && make install && cd / && rm -rf /deps/libsodium-1.0.20*
# libzmq 4.3.5
RUN wget -q https://github.com/zeromq/libzmq/releases/download/v4.3.5/zeromq-4.3.5.tar.gz && \
tar xf zeromq-4.3.5.tar.gz && cd zeromq-4.3.5 && \
./configure --enable-static --disable-shared --prefix=/usr --without-docs --enable-drafts=no && \
make -j"$(nproc)" && make install && cd / && rm -rf /deps/zeromq-4.3.5*
# expat 2.6.4
RUN wget -q https://github.com/libexpat/libexpat/releases/download/R_2_6_4/expat-2.6.4.tar.bz2 && \
tar xf expat-2.6.4.tar.bz2 && cd expat-2.6.4 && \
./configure --enable-static --disable-shared --prefix=/usr && \
make -j"$(nproc)" && make install && cd / && rm -rf /deps/expat-2.6.4*
# unbound 1.25.1(DNSSEC,与 Monero v0.18.5.1 depends 对齐)
RUN wget -q https://www.nlnetlabs.nl/downloads/unbound/unbound-1.25.1.tar.gz && \
tar xf unbound-1.25.1.tar.gz && cd unbound-1.25.1 && \
./configure --disable-shared --enable-static --prefix=/usr --with-libexpat=/usr --with-ssl=/usr \
--with-libevent=no --without-pythonmodule --without-pyunbound --with-libunbound-only --with-pic && \
make -j"$(nproc)" && make install && cd / && rm -rf /deps/unbound*
# ---- Stage 2: 换名 + patch + 编译 mond ----
FROM deps AS build
ARG MONERO_VERSION
ARG TARGETARCH
WORKDIR /src
RUN git clone --recursive --branch "${MONERO_VERSION}" --depth 1 --shallow-submodules \
https://github.com/monero-project/monero.git monero
WORKDIR /src/monero
# init.sh:monero→mond 换名 + musl fully-static patch(去 -pie、STATIC_FLAGS 改 -static)
COPY ./init.sh ./init.sh
RUN sh ./init.sh
RUN if [ "$TARGETARCH" = "arm64" ]; then MARCH=armv8-a; MTAG=linux-armv8; \
else MARCH=x86-64; MTAG=linux-x64; fi && \
cmake -S . -B build/release -DSTATIC=ON -DSTACK_TRACE=OFF -DBUILD_64=ON \
-DCMAKE_BUILD_TYPE=Release -DARCH="$MARCH" -DBUILD_TAG="$MTAG" -DUSE_DEVICE_TREZOR=OFF && \
make -j"$(nproc)" -C build/release daemon && \
mkdir -p /output && cp build/release/bin/mond /output/mond
# ---- Stage 3: 导出(保持 CI 期望的 linux_<arch>/mond 布局)----
FROM scratch
ARG TARGETARCH
COPY --from=build /output/mond /linux_${TARGETARCH}/mond
-83
View File
@@ -1,83 +0,0 @@
FROM ubuntu:20.04 AS base
ARG TARGETARCH
ARG BUILDPLATFORM
ENV DEBIAN_FRONTEND=noninteractive
# 安装构建依赖(包括 depends 系统所需工具)
RUN apt-get update && apt-get install -y \
git \
wget \
curl \
build-essential \
cmake \
pkg-config \
autoconf \
automake \
libtool \
bzip2 \
xz-utils \
python3 \
gperf \
libboost-all-dev \
libssl-dev \
libzmq3-dev \
libunbound-dev \
libsodium-dev \
libunwind8-dev \
liblzma-dev \
libreadline-dev \
libexpat1-dev \
libpgm-dev \
qttools5-dev-tools \
libhidapi-dev \
libusb-1.0-0-dev \
libprotobuf-dev \
protobuf-compiler \
libudev-dev \
libgtest-dev \
&& rm -rf /var/lib/apt/lists/*
FROM base AS build
ARG MONERO_VERSION=v0.18.3.4
ARG TARGETARCH
ARG BUILDPLATFORM
ARG TARGETPLATFORM
# 克隆 Monero 项目
RUN git clone --recursive https://github.com/monero-project/monero.git && \
cd monero && \
git checkout ${MONERO_VERSION} && \
git submodule update --init --force
WORKDIR /monero
# 复制并运行 init.sh 脚本进行修改
COPY ./init.sh ./init.sh
RUN chmod +x ./init.sh && ./init.sh
# 使用官方 depends 系统构建静态依赖(参考 .source/Dockerfile)
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
MAKE_JOBS=2; \
else \
MAKE_JOBS=$(nproc); \
fi && \
if [ "$TARGETARCH" = "arm64" ]; then \
DEPENDS_TARGET="aarch64-linux-gnu"; \
else \
DEPENDS_TARGET="x86_64-linux-gnu"; \
fi && \
echo "Building dependencies for $DEPENDS_TARGET with $MAKE_JOBS parallel jobs" && \
make -j$MAKE_JOBS depends target=$DEPENDS_TARGET && \
mkdir -p /output && \
cp build/$DEPENDS_TARGET/release/bin/mond /output/mond
# 最终阶段 - 只复制静态链接的二进制文件
FROM scratch
ARG TARGETARCH
COPY --from=build /output/mond /linux_${TARGETARCH}/mond
+31
View File
@@ -1,4 +1,22 @@
#!/bin/sh
set -eu
require_pattern() {
pattern=$1
file=$2
grep -Fq -- "$pattern" "$file" || {
echo "Required patch anchor not found in $file: $pattern" >&2
exit 1
}
}
require_pattern 'project(monero)' CMakeLists.txt
require_pattern 'OUTPUT_NAME "monerod"' src/daemon/CMakeLists.txt
require_pattern '${monero_SOURCE_DIR}' cmake/CheckLinkerFlag.cmake
require_pattern 'DEF_MONERO_VERSION' src/version.cpp.in
require_pattern 'DEF_MONERO_RELEASE_NAME "Fluorine Fermi"' src/version.cpp.in
require_pattern 'add_linker_flag_if_supported("-pie" LD_SECURITY_FLAGS)' CMakeLists.txt
require_pattern 'set(STATIC_FLAGS "-static-libgcc -static-libstdc++")' CMakeLists.txt
# Modify the CMakeLists.txt and source files to change the project name from "monero" to "mond"
@@ -50,6 +68,19 @@ find tests -type f -name "*.cpp" -exec sed -i 's/"Monero '"'"'/"Mond '"'"'/g' {}
# Uncomment the following lines if you want to remove Monero Project copyright
# find . -type f \( -name "*.cpp" -o -name "*.h" \) -exec sed -i '/Copyright.*The Monero Project/d' {} \;
# 8. musl fully-static patch(配合 docker/Dockerfile,产出无 interpreter、零外部依赖的 static-pie)
# monero 官方"不支持 fully static":STATIC=ON 在 Linux 仅给 -static-libgcc/-static-libstdc++,且强制 -pie。
# 去掉 -pie(否则强制动态 PIE/带 musl interpreter,无法跨发行版)
sed -i 's|add_linker_flag_if_supported("-pie" LD_SECURITY_FLAGS)|# -pie removed for fully-static|' CMakeLists.txt
# Linux STATIC_FLAGS 从 -static-libgcc/-static-libstdc++ 改真 -static
sed -i 's|set(STATIC_FLAGS "-static-libgcc -static-libstdc++")|set(STATIC_FLAGS "-static")|' CMakeLists.txt
require_pattern 'project(mond)' CMakeLists.txt
require_pattern 'OUTPUT_NAME "mond"' src/daemon/CMakeLists.txt
require_pattern 'DEF_MOND_VERSION' src/version.cpp.in
require_pattern '# -pie removed for fully-static' CMakeLists.txt
require_pattern 'set(STATIC_FLAGS "-static")' CMakeLists.txt
echo "Project successfully modified from Monero to Mond!"
echo "Binary output name: mond"
echo "Project name: mond"