初始化 XXXig 打包部署脚本与 CI 流水线
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 1m12s
Build and Release / build-and-test (amd64, alpine) (push) Successful in 1m21s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 5m24s
Build and Release / build-and-test (arm64, alpine) (push) Successful in 6m8s
Build and Release / release (push) Has been skipped
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 1m12s
Build and Release / build-and-test (amd64, alpine) (push) Successful in 1m21s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 5m24s
Build and Release / build-and-test (arm64, alpine) (push) Successful in 6m8s
Build and Release / release (push) Has been skipped
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+93
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# 参数检查
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
|
||||
echo "Example: $0 amd64 6.26.0 xxxig-amd64-ubuntu-6.26.0.tar.gz"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ARCH=$1
|
||||
VERSION=$2
|
||||
TARGZ_FILE=$3
|
||||
PKG_NAME="xxxig"
|
||||
DEB_VERSION="${VERSION#v}" # Debian 版本号必须以数字开头,去掉可能的 v 前缀
|
||||
|
||||
# 转换架构名称(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"
|
||||
mkdir -p "${PKG_DIR}/lib/systemd/system"
|
||||
|
||||
# 解压二进制文件
|
||||
echo "📂 Extracting binaries..."
|
||||
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/xxxig"
|
||||
|
||||
# 生成 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 services..."
|
||||
cp debian/xxxig-server.service "${PKG_DIR}/lib/systemd/system/"
|
||||
cp debian/xxxig-daemon.service "${PKG_DIR}/lib/systemd/system/"
|
||||
|
||||
# 设置权限
|
||||
chmod 755 "${PKG_DIR}/opt/xxxig/xxxigServer"
|
||||
chmod 755 "${PKG_DIR}/opt/xxxig/xxxigDaemon"
|
||||
chmod 755 "${PKG_DIR}/opt/xxxig/xxxig"
|
||||
chmod 644 "${PKG_DIR}/opt/xxxig/config.json"
|
||||
chmod 644 "${PKG_DIR}/opt/xxxig/config_cc.json"
|
||||
chmod 644 "${PKG_DIR}/opt/xxxig/index.html"
|
||||
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-server.service"
|
||||
chmod 644 "${PKG_DIR}/lib/systemd/system/xxxig-daemon.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!"
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
Package: xxxig
|
||||
Version: {{VERSION}}
|
||||
Section: net
|
||||
Priority: optional
|
||||
Architecture: {{ARCH}}
|
||||
Depends: libc6, libuv1, libssl3 | libssl1.1, libhwloc15 | libhwloc5
|
||||
Maintainer: XXXig Team <noreply@example.com>
|
||||
Homepage: https://github.com/wangdefaa/xxxig
|
||||
Description: Cryptocurrency mining software suite
|
||||
XXXig is a customized build of XMRig,
|
||||
a cryptocurrency mining software with centralized management.
|
||||
.
|
||||
This package includes:
|
||||
- xxxigServer: Central control server with web UI
|
||||
- xxxigDaemon: Client daemon that connects to the server
|
||||
- xxxig: Mining executable controlled by the daemon
|
||||
- Systemd service configurations
|
||||
- Default configuration files
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Create user and group if they don't exist
|
||||
if ! getent group xxxig >/dev/null; then
|
||||
addgroup --system xxxig
|
||||
fi
|
||||
|
||||
if ! getent passwd xxxig >/dev/null; then
|
||||
adduser --system --ingroup xxxig --no-create-home \
|
||||
--home /opt/xxxig --shell /usr/sbin/nologin \
|
||||
--gecos "XXXig Service" xxxig
|
||||
fi
|
||||
|
||||
# Create log directory
|
||||
mkdir -p /var/log/xxxig
|
||||
chown xxxig:xxxig /var/log/xxxig
|
||||
chmod 750 /var/log/xxxig
|
||||
|
||||
# Create config directory
|
||||
mkdir -p /etc/xxxig
|
||||
|
||||
# Copy default configs if they don't exist
|
||||
if [ ! -f /etc/xxxig/config.json ]; then
|
||||
cp /opt/xxxig/config.json /etc/xxxig/config.json
|
||||
chown xxxig:xxxig /etc/xxxig/config.json
|
||||
chmod 640 /etc/xxxig/config.json
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/xxxig/config_cc.json ]; then
|
||||
cp /opt/xxxig/config_cc.json /etc/xxxig/config_cc.json
|
||||
chown xxxig:xxxig /etc/xxxig/config_cc.json
|
||||
chmod 640 /etc/xxxig/config_cc.json
|
||||
fi
|
||||
|
||||
# Set permissions
|
||||
chown -R root:root /opt/xxxig
|
||||
chmod -R 755 /opt/xxxig
|
||||
|
||||
# Reload systemd
|
||||
if [ -d /run/systemd/system ]; then
|
||||
systemctl daemon-reload
|
||||
|
||||
# 升级时重启正在运行的服务以加载新二进制;try-restart 不会启动未运行的服务,
|
||||
# 故首次安装仍保持"不自动启动"语义
|
||||
systemctl try-restart xxxig-daemon.service xxxig-server.service 2>/dev/null || true
|
||||
|
||||
# Note: Services are NOT auto-enabled or auto-started
|
||||
# Users should manually enable the services they need:
|
||||
# systemctl enable xxxig-server.service
|
||||
# systemctl start xxxig-server.service
|
||||
# or
|
||||
# systemctl enable xxxig-daemon.service
|
||||
# systemctl start xxxig-daemon.service
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "✅ XXXig installed successfully!"
|
||||
echo ""
|
||||
echo "📁 Important paths:"
|
||||
echo " Config files: /etc/xxxig/config.json (daemon)"
|
||||
echo " /etc/xxxig/config_cc.json (server)"
|
||||
echo " Log directory: /var/log/xxxig"
|
||||
echo " Binaries: /opt/xxxig/xxxigServer (control server)"
|
||||
echo " /opt/xxxig/xxxigDaemon (mining daemon)"
|
||||
echo " /opt/xxxig/xxxig (miner executable)"
|
||||
echo " Systemd services: xxxig-server.service (control server)"
|
||||
echo " xxxig-daemon.service (mining daemon)"
|
||||
echo ""
|
||||
echo "💡 Tip: Your config files will NOT be overwritten during package upgrades."
|
||||
echo ""
|
||||
|
||||
exit 0
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
purge)
|
||||
# Remove user and group
|
||||
if getent passwd xxxig >/dev/null; then
|
||||
deluser --quiet xxxig || true
|
||||
fi
|
||||
|
||||
if getent group xxxig >/dev/null; then
|
||||
delgroup --quiet xxxig || true
|
||||
fi
|
||||
|
||||
# Remove data directories (only on purge)
|
||||
rm -rf /var/log/xxxig
|
||||
rm -rf /etc/xxxig
|
||||
;;
|
||||
|
||||
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||
# Do nothing
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postrm called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Reload systemd
|
||||
if [ -d /run/systemd/system ]; then
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
exit 0
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# 仅在卸载(remove)时停用服务;升级(upgrade)时保持运行与开机自启状态
|
||||
if [ "$1" = "remove" ] && [ -d /run/systemd/system ]; then
|
||||
for service in xxxig-server.service xxxig-daemon.service; do
|
||||
if systemctl is-active --quiet "$service"; then
|
||||
echo "Stopping $service..."
|
||||
systemctl stop "$service"
|
||||
fi
|
||||
|
||||
if systemctl is-enabled --quiet "$service"; then
|
||||
echo "Disabling $service..."
|
||||
systemctl disable "$service"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
[Unit]
|
||||
Description=XXXig Daemon (Miner Client)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
# 工作目录
|
||||
WorkingDirectory=/opt/xxxig
|
||||
|
||||
# 执行命令
|
||||
ExecStart=/opt/xxxig/xxxigDaemon --config /etc/xxxig/config.json --log-file=/var/log/xxxig/daemon.log
|
||||
|
||||
# 重启策略
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
# 用户和组
|
||||
User=xxxig
|
||||
Group=xxxig
|
||||
|
||||
# 安全设置
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/var/log/xxxig
|
||||
|
||||
# 日志设置
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=xxxig-daemon
|
||||
|
||||
# 资源限制
|
||||
LimitNOFILE=65535
|
||||
LimitMEMLOCK=infinity
|
||||
AmbientCapabilities=CAP_IPC_LOCK
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
[Unit]
|
||||
Description=XXXig Server (Control Center)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
# 工作目录
|
||||
WorkingDirectory=/opt/xxxig
|
||||
|
||||
# 执行命令
|
||||
ExecStart=/opt/xxxig/xxxigServer --config /etc/xxxig/config_cc.json --log-file=/var/log/xxxig/server.log
|
||||
|
||||
# 重启策略
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
# 用户和组
|
||||
User=xxxig
|
||||
Group=xxxig
|
||||
|
||||
# 安全设置
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/var/log/xxxig
|
||||
|
||||
# 日志设置
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=xxxig-server
|
||||
|
||||
# 资源限制
|
||||
LimitNOFILE=65535
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user