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>
This commit is contained in:
2026-06-09 22:00:48 +08:00
co-authored by Claude Opus 4.8
parent 2862374985
commit 317973e94d
11 changed files with 184 additions and 227 deletions
+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.6 build/Linux/release/bin"
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
echo "Example: $0 amd64 0.18.5.0 mond-amd64-ubuntu-0.18.5.0.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 -1
View File
@@ -3,7 +3,7 @@ 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
Depends: libc6 (>= 2.31)
Maintainer: Mond Team <noreply@example.com>
Homepage: https://github.com/monero-project/monero
Description: Mond cryptocurrency daemon
+1 -1
View File
@@ -9,7 +9,7 @@ Type=simple
WorkingDirectory=/opt/mond
# 执行命令 - 使用配置文件
ExecStart=/opt/mond/mond --config-file=/var/lib/mond/params.conf --non-interactive
ExecStart=/opt/mond/mond --config-file=/etc/mond/params.conf --non-interactive
# 重启策略
Restart=always
+32 -134
View File
@@ -17,128 +17,43 @@ mkdir -p /var/log/mond
chown mond:mond /var/log/mond
chmod 750 /var/log/mond
# Create data directory
# Create data directory(非递归设权限,避免升级时遍历庞大的区块链数据目录)
mkdir -p /var/lib/mond/data
chown -R mond:mond /var/lib/mond
chmod -R 750 /var/lib/mond
chown mond:mond /var/lib/mond /var/lib/mond/data
chmod 750 /var/lib/mond /var/lib/mond/data
# Create configuration file if it doesn't exist
if [ ! -f /var/lib/mond/params.conf ]; then
cat > /var/lib/mond/params.conf << 'CONF'
# 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
# Create config directory
mkdir -p /etc/mond
# DATA STORAGE
# ============================================================================
# data-dir: 区块链数据存储目录
data-dir=/var/lib/mond/data
# BLOCKCHAIN PRUNING
# ============================================================================
# prune-blockchain: 启用区块链修剪模式
prune-blockchain=1
# sync-pruned-blocks: 同步已修剪的区块(默认启用)
sync-pruned-blocks=1
# NETWORK PEER SETTINGS
# ============================================================================
# out-peers: 主动连接的对等节点数量(出站连接)
out-peers=32
# in-peers: 接受连接的对等节点数量(入站连接)
in-peers=64
# limit-rate-up: 上传速率限制(kB/s
limit-rate-up=1048576
# limit-rate-down: 下载速率限制(kB/s
limit-rate-down=1048576
# PRIORITY NODES
# ============================================================================
# add-priority-node: 优先连接的可信节点
add-priority-node=p2pmd.xmrvsbeast.com:18080
add-priority-node=nodes.hashvault.pro:18080
# SECURITY AND NETWORK INTEGRITY
# ============================================================================
# enforce-dns-checkpointing: 强制执行 DNS 检查点验证
enforce-dns-checkpointing=1
# enable-dns-blocklist: 启用 DNS 黑名单
enable-dns-blocklist=1
# ZMQ NOTIFICATION SYSTEM
# ============================================================================
# zmq-pub: ZeroMQ 发布接口,用于实时广播区块链事件
zmq-pub=tcp://127.0.0.1:18083
# P2P AND RPC NETWORK BINDING
# ============================================================================
# p2p-bind-ip: P2P 网络监听地址(默认启用,绑定所有网络接口)
p2p-bind-ip=0.0.0.0
# p2p-bind-port: P2P 网络监听端口
p2p-bind-port=18080
# rpc-bind-ip: RPC 接口监听地址
#rpc-bind-ip=0.0.0.0
# rpc-bind-port: RPC 接口监听端口
#rpc-bind-port=18081
# confirm-external-bind: 确认外部网络绑定
#confirm-external-bind=1
# RPC AUTHENTICATION
# ============================================================================
# rpc-login: RPC 访问认证凭据
#rpc-login=user:password
# RPC SSL/TLS ENCRYPTION
# ============================================================================
# rpc-ssl: 启用 RPC 连接的 SSL/TLS 加密(语义更清晰的启用方式)
#rpc-ssl=enabled
# rpc-ssl-certificate: SSL 证书文件路径
#rpc-ssl-certificate=/path/to/your/certificate.pem
# rpc-ssl-private-key: SSL 私钥文件路径
#rpc-ssl-private-key=/path/to/your/private_key.pem
# LOGGING SETTINGS
# ============================================================================
# log-level: 日志详细程度(调整为详细日志级别)
log-level=1
# log-file: 日志文件保存路径
log-file=/var/log/mond/mond.log
CONF
chown mond:mond /var/lib/mond/params.conf
chmod 640 /var/lib/mond/params.conf
# 兼容旧版本:配置文件曾位于 /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
# Set permissions on binary
chown root:root /opt/mond/mond
# 首次安装:从包内默认配置生成(源: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 and handle service restart on upgrade
# Reload systemd
if [ -d /run/systemd/system ]; then
systemctl daemon-reload
# On upgrade: restart service if it was enabled
if [ "$1" = "configure" ] && [ -n "$2" ]; then
# $2 is the previously installed version (only set on upgrade)
if systemctl is-enabled --quiet mond.service 2>/dev/null; then
echo "Restarting mond service after upgrade..."
systemctl start mond.service || true
fi
fi
# 升级时重启正在运行的服务以加载新二进制;try-restart 不会启动未运行的服务,
# 故首次安装仍保持"不自动启动"语义
systemctl try-restart mond.service 2>/dev/null || true
# Note: On fresh install, service is NOT auto-enabled or auto-started
# Users should manually enable the service:
# systemctl enable mond.service
# systemctl start mond.service
fi
@@ -146,31 +61,14 @@ fi
echo ""
echo "✅ Mond installed successfully!"
echo ""
echo "📋 Configuration and startup:"
echo ""
echo "1. Review and configure settings (optional):"
echo " sudo nano /var/lib/mond/params.conf"
echo ""
echo " Adjust network settings, peer connections, and other options as needed."
echo ""
echo "2. Start Mond:"
echo " sudo systemctl enable mond.service"
echo " sudo systemctl start mond.service"
echo ""
echo "3. Check status:"
echo " sudo systemctl status mond.service"
echo " sudo journalctl -u mond -f"
echo ""
echo "📁 Important paths:"
echo " Config file: /var/lib/mond/params.conf"
echo " Data directory: /var/lib/mond/data"
echo " Log directory: /var/log/mond"
echo " Binary: /opt/mond/mond"
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 "💡 Tip: Your params.conf will NOT be overwritten during package upgrades."
echo ""
echo "For help:"
echo " /opt/mond/mond --help"
echo "💡 Tip: Your config files will NOT be overwritten during package upgrades."
echo ""
exit 0
+2 -1
View File
@@ -12,9 +12,10 @@ case "$1" in
delgroup --quiet mond || true
fi
# Remove data directories (only on purge)
# Remove data/config directories (only on purge)
rm -rf /var/log/mond
rm -rf /var/lib/mond
rm -rf /etc/mond
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+13 -31
View File
@@ -1,36 +1,18 @@
#!/bin/sh
set -e
case "$1" in
upgrade)
# 升级时只停止服务,保留 enabled 状态
if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet mond.service; then
echo "Stopping mond service for upgrade..."
systemctl stop mond.service
fi
fi
;;
remove|deconfigure)
# 删除时停止并禁用服务
if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet mond.service; then
echo "Stopping mond service..."
systemctl stop mond.service
fi
if systemctl is-enabled --quiet mond.service 2>/dev/null; then
echo "Disabling mond service..."
systemctl disable mond.service
fi
fi
;;
failed-upgrade)
# 升级失败时不做操作
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
# 仅在卸载(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
fi
if systemctl is-enabled --quiet mond.service 2>/dev/null; then
echo "Disabling mond service..."
systemctl disable mond.service
fi
fi
exit 0