重构为 musl 纯静态打包,配置迁 /etc,对齐三项目
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Vendored
+6
-2
@@ -4,7 +4,7 @@ set -e
|
||||
# 参数检查
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
|
||||
echo "Example: $0 amd64 v4.15.1 p2pool-amd64-ubuntu-v4.15.1.tar.gz"
|
||||
echo "Example: $0 amd64 4.15.1 p2pool-amd64-linux-static-4.15.1.tar.gz"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -45,12 +45,15 @@ PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}"
|
||||
mkdir -p "${PKG_DIR}/DEBIAN"
|
||||
mkdir -p "${PKG_DIR}/opt/p2pool"
|
||||
mkdir -p "${PKG_DIR}/lib/systemd/system"
|
||||
mkdir -p "${PKG_DIR}/etc/p2pool"
|
||||
|
||||
# 解压二进制文件
|
||||
echo "📂 Extracting binaries..."
|
||||
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/p2pool"
|
||||
|
||||
# 打入默认配置(conf/params.conf.example 为唯一配置源,postinst 据此生成 /etc/p2pool/params.conf)
|
||||
echo "📄 Bundling default config..."
|
||||
cp conf/params.conf.example "${PKG_DIR}/opt/p2pool/params.conf"
|
||||
|
||||
# 生成 control 文件
|
||||
echo "📝 Generating control file..."
|
||||
sed -e "s/{{VERSION}}/${DEB_VERSION}/" \
|
||||
@@ -72,6 +75,7 @@ cp debian/p2pool.service "${PKG_DIR}/lib/systemd/system/"
|
||||
|
||||
# 设置权限
|
||||
chmod 755 "${PKG_DIR}/opt/p2pool/p2pool"
|
||||
chmod 644 "${PKG_DIR}/opt/p2pool/params.conf"
|
||||
chmod 644 "${PKG_DIR}/lib/systemd/system/p2pool.service"
|
||||
|
||||
# 构建 deb 包
|
||||
|
||||
Vendored
-1
@@ -3,7 +3,6 @@ Version: {{VERSION}}
|
||||
Section: net
|
||||
Priority: optional
|
||||
Architecture: {{ARCH}}
|
||||
Depends: libc6, libuv1, libzmq5, libcurl4
|
||||
Maintainer: P2Pool Team <noreply@example.com>
|
||||
Homepage: https://github.com/SChernykh/p2pool
|
||||
Description: Decentralized pool for Monero mining
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ Type=simple
|
||||
User=p2pool
|
||||
Group=p2pool
|
||||
WorkingDirectory=/var/lib/p2pool
|
||||
ExecStart=/opt/p2pool/p2pool --params-file /var/lib/p2pool/params.conf
|
||||
ExecStart=/opt/p2pool/p2pool --params-file /etc/p2pool/params.conf
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
StandardOutput=journal
|
||||
|
||||
Vendored
+39
-84
@@ -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
|
||||
|
||||
Vendored
+2
-1
@@ -12,9 +12,10 @@ case "$1" in
|
||||
delgroup --quiet p2pool || true
|
||||
fi
|
||||
|
||||
# Remove data directories (only on purge)
|
||||
# Remove data/config directories (only on purge)
|
||||
rm -rf /var/lib/p2pool
|
||||
rm -rf /var/log/p2pool
|
||||
rm -rf /etc/p2pool
|
||||
;;
|
||||
|
||||
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||
|
||||
Vendored
+17
-32
@@ -1,33 +1,18 @@
|
||||
case "$1" in
|
||||
upgrade)
|
||||
# Stop service only during upgrade, keep enabled state
|
||||
if [ -d /run/systemd/system ]; then
|
||||
if systemctl is-active --quiet p2pool.service; then
|
||||
echo "Stopping p2pool service for upgrade..."
|
||||
systemctl stop p2pool.service
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
remove|deconfigure)
|
||||
# Stop and disable service during removal
|
||||
if [ -d /run/systemd/system ]; then
|
||||
if systemctl is-active --quiet p2pool.service; then
|
||||
echo "Stopping p2pool service..."
|
||||
systemctl stop p2pool.service
|
||||
fi
|
||||
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
|
||||
echo "Disabling p2pool service..."
|
||||
systemctl disable p2pool.service
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
failed-upgrade)
|
||||
# Do nothing on failed upgrade
|
||||
;;
|
||||
*)
|
||||
echo "prerm called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
exit 0
|
||||
# 仅在卸载(remove)时停用服务;升级(upgrade)时保持运行,
|
||||
# 由 postinst 的 try-restart 重启以加载新二进制
|
||||
if [ "$1" = "remove" ] && [ -d /run/systemd/system ]; then
|
||||
if systemctl is-active --quiet p2pool.service; then
|
||||
echo "Stopping p2pool service..."
|
||||
systemctl stop p2pool.service
|
||||
fi
|
||||
|
||||
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
|
||||
echo "Disabling p2pool service..."
|
||||
systemctl disable p2pool.service
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user