Files
wangdefaandClaude Opus 4.8 317973e94d
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
feat: 对齐 xxxig/proxy 打包规范并迁移配置至 /etc/mond
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 22:00:48 +08:00

75 lines
2.4 KiB
Bash
Executable File
Raw Permalink 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.
#!/bin/sh
set -e
# Create user and group if they don't exist
if ! getent group mond >/dev/null; then
addgroup --system mond
fi
if ! getent passwd mond >/dev/null; then
adduser --system --ingroup mond --no-create-home \
--home /var/lib/mond --shell /usr/sbin/nologin \
--gecos "Mond Cryptocurrency Daemon" mond
fi
# Create log directory
mkdir -p /var/log/mond
chown mond:mond /var/log/mond
chmod 750 /var/log/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
# 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
# 升级时重启正在运行的服务以加载新二进制;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
echo ""
echo "✅ Mond installed successfully!"
echo ""
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 "💡 Tip: Your config files will NOT be overwritten during package upgrades."
echo ""
exit 0