初始化 proxy 打包项目,对齐 xxxig 矿工项目
Build and Release / build-and-test (amd64, alpine) (push) Successful in 20s
Build and Release / build-and-test (arm64, alpine) (push) Successful in 42s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 27s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 9s
Build and Release / release (push) Has been skipped

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Wang Defa
2026-06-09 16:38:30 +08:00
co-authored by Claude Opus 4.8
commit 116023cd24
12 changed files with 740 additions and 0 deletions
Vendored Executable
+89
View File
@@ -0,0 +1,89 @@
#!/bin/bash
set -e
# 参数检查
if [ $# -ne 3 ]; then
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
echo "Example: $0 amd64 6.26.0 xxxig-proxy-amd64-ubuntu-6.26.0.tar.gz"
exit 1
fi
ARCH=$1
VERSION=$2
TARGZ_FILE=$3
PKG_NAME="xxxig-proxy"
DEB_VERSION="${VERSION#v}" # Debian 版本号必须以数字开头,去掉可能的 v 前缀
[ -f "$TARGZ_FILE" ] || { echo "❌ 找不到产物包: $TARGZ_FILE"; exit 1; }
# 转换架构名称(Docker 使用的架构名到 Debian 架构名)
case "$ARCH" in
amd64)
DEB_ARCH="amd64"
;;
arm64)
DEB_ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
DEB_FILE="${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}.deb"
echo "📦 Building Debian package: ${DEB_FILE}"
echo " Architecture: ${DEB_ARCH}"
echo " Version: ${DEB_VERSION}"
echo " Source: ${TARGZ_FILE}"
# 创建临时目录
BUILD_DIR=$(mktemp -d)
trap "rm -rf $BUILD_DIR" EXIT
# 创建包目录结构
PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}"
mkdir -p "${PKG_DIR}/DEBIAN"
mkdir -p "${PKG_DIR}/opt/xxxig-proxy"
mkdir -p "${PKG_DIR}/lib/systemd/system"
# 解压二进制文件
echo "📂 Extracting binary..."
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/xxxig-proxy"
# 生成 control 文件
echo "📝 Generating control file..."
sed -e "s/{{VERSION}}/${DEB_VERSION}/" \
-e "s/{{ARCH}}/${DEB_ARCH}/" \
debian/control.template > "${PKG_DIR}/DEBIAN/control"
# 复制维护脚本
echo "📋 Copying maintainer scripts..."
cp debian/postinst "${PKG_DIR}/DEBIAN/postinst"
cp debian/prerm "${PKG_DIR}/DEBIAN/prerm"
cp debian/postrm "${PKG_DIR}/DEBIAN/postrm"
chmod 755 "${PKG_DIR}/DEBIAN/postinst"
chmod 755 "${PKG_DIR}/DEBIAN/prerm"
chmod 755 "${PKG_DIR}/DEBIAN/postrm"
# 复制 systemd service 文件
echo "🔧 Installing systemd service..."
cp debian/xxxig-proxy.service "${PKG_DIR}/lib/systemd/system/"
# 设置权限
chmod 755 "${PKG_DIR}/opt/xxxig-proxy/xxxig-proxy"
chmod 644 "${PKG_DIR}/opt/xxxig-proxy/config.json"
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-proxy.service"
# 构建 deb 包
echo "🔨 Building package..."
dpkg-deb --build --root-owner-group "${PKG_DIR}" "${DEB_FILE}"
# 检查包
echo "✅ Package built successfully!"
echo "📦 Package: $(pwd)/${DEB_FILE}"
echo "📊 Package info:"
dpkg-deb --info "${DEB_FILE}"
echo ""
echo "🎉 Done!"
+16
View File
@@ -0,0 +1,16 @@
Package: xxxig-proxy
Version: {{VERSION}}
Section: net
Priority: optional
Architecture: {{ARCH}}
Depends: libc6 (>= 2.31)
Maintainer: XXXig Team <noreply@example.com>
Homepage: https://github.com/wangdefaa/xxxig-proxy
Description: Cryptocurrency mining proxy
XXXig Proxy is a customized build of xmrig-proxy,
a cryptocurrency mining proxy server.
.
This package includes:
- The xxxig-proxy binary
- Systemd service configuration
- Default configuration file
+61
View File
@@ -0,0 +1,61 @@
#!/bin/sh
set -e
# Create user and group if they don't exist
if ! getent group xxxig-proxy >/dev/null; then
addgroup --system xxxig-proxy
fi
if ! getent passwd xxxig-proxy >/dev/null; then
adduser --system --ingroup xxxig-proxy --no-create-home \
--home /opt/xxxig-proxy --shell /usr/sbin/nologin \
--gecos "XXXig Proxy Service" xxxig-proxy
fi
# Create log directory
mkdir -p /var/log/xxxig-proxy
chown xxxig-proxy:xxxig-proxy /var/log/xxxig-proxy
chmod 750 /var/log/xxxig-proxy
# Create config directory
mkdir -p /etc/xxxig-proxy
# Copy default config if it doesn't exist
if [ ! -f /etc/xxxig-proxy/config.json ]; then
cp /opt/xxxig-proxy/config.json /etc/xxxig-proxy/config.json
chown xxxig-proxy:xxxig-proxy /etc/xxxig-proxy/config.json
chmod 640 /etc/xxxig-proxy/config.json
fi
# Set permissions:目录与二进制 755,配置等数据文件 644
chown -R root:root /opt/xxxig-proxy
find /opt/xxxig-proxy -type d -exec chmod 755 {} +
find /opt/xxxig-proxy -type f -exec chmod 644 {} +
chmod 755 /opt/xxxig-proxy/xxxig-proxy
# Reload systemd
if [ -d /run/systemd/system ]; then
systemctl daemon-reload
# 升级时重启正在运行的服务以加载新二进制;try-restart 不会启动未运行的服务,
# 故首次安装仍保持"不自动启动"语义(默认上游为 localhost,需用户改配置后再启用)
systemctl try-restart xxxig-proxy.service 2>/dev/null || true
# Note: Service is NOT auto-enabled or auto-started
# systemctl enable xxxig-proxy.service
# systemctl start xxxig-proxy.service
fi
echo ""
echo "✅ XXXig Proxy installed successfully!"
echo ""
echo "📁 Important paths:"
echo " Config files: /etc/xxxig-proxy/config.json"
echo " Log directory: /var/log/xxxig-proxy"
echo " Binaries: /opt/xxxig-proxy/xxxig-proxy"
echo " Systemd services: xxxig-proxy.service"
echo ""
echo "💡 Tip: Your config files will NOT be overwritten during package upgrades."
echo ""
exit 0
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh
set -e
case "$1" in
purge)
# Remove log directory
rm -rf /var/log/xxxig-proxy
# Remove config directory
rm -rf /etc/xxxig-proxy
# Remove user and group
if getent passwd xxxig-proxy >/dev/null; then
deluser --system xxxig-proxy 2>/dev/null || true
fi
if getent group xxxig-proxy >/dev/null; then
delgroup --system xxxig-proxy 2>/dev/null || true
fi
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
# Reload systemd
if [ -d /run/systemd/system ]; then
systemctl daemon-reload
fi
;;
esac
exit 0
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
set -e
# Stop service before removal
if [ -d /run/systemd/system ]; then
if systemctl is-active xxxig-proxy.service >/dev/null 2>&1; then
systemctl stop xxxig-proxy.service
fi
if systemctl is-enabled xxxig-proxy.service >/dev/null 2>&1; then
systemctl disable xxxig-proxy.service
fi
fi
exit 0
+39
View File
@@ -0,0 +1,39 @@
[Unit]
Description=XXXig Proxy Service
After=network.target
[Service]
Type=simple
# 工作目录
WorkingDirectory=/opt/xxxig-proxy
# 执行命令
ExecStart=/opt/xxxig-proxy/xxxig-proxy --config=/etc/xxxig-proxy/config.json --log-file=/var/log/xxxig-proxy/proxy.log --access-log-file=/var/log/xxxig-proxy/access.log
# 重启策略
Restart=always
RestartSec=10
# 用户和组
User=xxxig-proxy
Group=xxxig-proxy
# 安全设置
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/log/xxxig-proxy
# 日志设置
StandardOutput=journal
StandardError=journal
SyslogIdentifier=xxxig-proxy
# 资源限制
LimitNOFILE=65535
LimitNPROC=4096
[Install]
WantedBy=multi-user.target