重构为 musl 纯静态打包,配置迁 /etc,对齐三项目
Build and Release / release (push) Has been skipped
Build and Release / build-and-test (amd64) (push) Failing after 3m8s
Build and Release / build-and-test (arm64) (push) Failing after 7m31s

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 14:55:12 +08:00
co-authored by Claude Opus 4.8
parent b222b802bf
commit 3b024fdc10
14 changed files with 307 additions and 312 deletions
+39 -84
View File
@@ -12,78 +12,48 @@ if ! getent passwd p2pool >/dev/null; then
--gecos "P2Pool Service" p2pool
fi
# Create data directory
mkdir -p /var/lib/p2pool/data-api
chown -R p2pool:p2pool /var/lib/p2pool
chmod -R 750 /var/lib/p2pool
# Create example params.conf if it doesn't exist
if [ ! -f /var/lib/p2pool/params.conf ]; then
cat > /var/lib/p2pool/params.conf << 'CONF'
# P2Pool Configuration File
# Edit this file with your settings and restart the service
# Monero node connection
host = 127.0.0.1
rpc-port = 18081
zmq-port = 18083
# Use SSL for RPC connection
# rpc-ssl = true
# RPC credentials (if applicable)
# rpc-login = username:password
# Your Monero wallet address (REQUIRED)
wallet = YOUR_MONERO_WALLET_ADDRESS
# P2P settings
p2p = 0.0.0.0:37889
# API settings
data-api = /var/lib/p2pool/data-api
local-api = true
# Logging
log-file = /var/log/p2pool/p2pool.log
loglevel = 3
# Mining mode (uncomment to enable mini sidechain)
# mini = true
# Merge mining (optional - uncomment to enable Tari merge mining)
# merge-mine = tari://TARI_NODE_IP:18142 TARI_WALLET_ADDRESS
# Stratum server (for miners to connect)
# stratum = 0.0.0.0:3333
CONF
chown p2pool:p2pool /var/lib/p2pool/params.conf
chmod 640 /var/lib/p2pool/params.conf
fi
# Create log directory
mkdir -p /var/log/p2pool
chown p2pool:p2pool /var/log/p2pool
chmod 750 /var/log/p2pool
# Set binary permissions
chown root:root /opt/p2pool/p2pool
# Create data directory(非递归设权限,避免升级时遍历庞大数据目录)
mkdir -p /var/lib/p2pool/data-api
chown p2pool:p2pool /var/lib/p2pool /var/lib/p2pool/data-api
chmod 750 /var/lib/p2pool /var/lib/p2pool/data-api
# Create config directory
mkdir -p /etc/p2pool
# 兼容旧版本:配置文件曾位于 /var/lib/p2pool/params.conf,迁移到 /etc/p2pool/params.conf
if [ ! -f /etc/p2pool/params.conf ] && [ -f /var/lib/p2pool/params.conf ]; then
echo "Migrating existing config from /var/lib/p2pool to /etc/p2pool..."
cp /var/lib/p2pool/params.conf /etc/p2pool/params.conf
fi
# 首次安装:从包内默认配置生成(源:conf/params.conf.example)。升级不覆盖已有配置
if [ ! -f /etc/p2pool/params.conf ]; then
cp /opt/p2pool/params.conf /etc/p2pool/params.conf
fi
chown p2pool:p2pool /etc/p2pool/params.conf
chmod 640 /etc/p2pool/params.conf
# Set permissions/opt 目录与二进制 755,数据文件 644(对齐 xxxig / xxxig-proxy / mond
chown -R root:root /opt/p2pool
find /opt/p2pool -type d -exec chmod 755 {} +
find /opt/p2pool -type f -exec chmod 644 {} +
chmod 755 /opt/p2pool/p2pool
# 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 p2pool.service 2>/dev/null; then
echo "Restarting p2pool service after upgrade..."
systemctl start p2pool.service || true
fi
fi
# 升级时重启正在运行的服务以加载新二进制;try-restart 不会启动未运行的服务,
# 故首次安装仍保持"不自动启动"语义
systemctl try-restart p2pool.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 p2pool.service
# systemctl start p2pool.service
fi
@@ -91,31 +61,16 @@ fi
echo ""
echo "✅ P2Pool installed successfully!"
echo ""
echo "📋 Before starting P2Pool, you MUST configure your settings:"
echo ""
echo "1. Edit the configuration file:"
echo " sudo nano /var/lib/p2pool/params.conf"
echo ""
echo " Set your Monero wallet address and adjust other settings as needed."
echo ""
echo "2. Start P2Pool:"
echo " sudo systemctl enable p2pool.service"
echo " sudo systemctl start p2pool.service"
echo ""
echo "3. Check status:"
echo " sudo systemctl status p2pool.service"
echo " sudo journalctl -u p2pool -f"
echo ""
echo "📁 Important paths:"
echo " Config file: /var/lib/p2pool/params.conf"
echo " Data directory: /var/lib/p2pool"
echo " Log directory: /var/log/p2pool"
echo " Binary: /opt/p2pool/p2pool"
echo " Config file: /etc/p2pool/params.conf"
echo " Data directory: /var/lib/p2pool/data-api"
echo " Log directory: /var/log/p2pool"
echo " Binaries: /opt/p2pool/p2pool"
echo " Systemd services: p2pool.service"
echo ""
echo "💡 Tip: Your params.conf will NOT be overwritten during package upgrades."
echo ""
echo "For help:"
echo " /opt/p2pool/p2pool --help"
echo "💡 Tip: Your config files will NOT be overwritten during package upgrades."
echo " Before starting, set your Monero wallet in /etc/p2pool/params.conf, then:"
echo " sudo systemctl enable --now p2pool.service"
echo ""
exit 0