优化部署,增加lisa dmit

This commit is contained in:
2026-08-05 09:51:12 +08:00
parent 81928c6d33
commit 2afc2cade6
9 changed files with 154 additions and 5 deletions
+75 -2
View File
@@ -61,16 +61,88 @@ fi
XRAY_PORT="${XRAY_PORT:-443}"
# ===== 0. 检查并安装依赖 =====
# 精简版系统镜像(如部分 VPS 商的 Debian/Ubuntu minimal)常缺 curl / unzip
ensure_deps() {
step "0/5 检查依赖"
local missing=()
local cmd
for cmd in curl unzip openssl; do
command -v "$cmd" &>/dev/null || missing+=("$cmd")
done
if [ ! -f /etc/ssl/certs/ca-certificates.crt ]; then
missing+=("ca-certificates")
fi
if [ "${#missing[@]}" -eq 0 ]; then
log "依赖齐全: curl unzip openssl ca-certificates"
return
fi
warn "缺少依赖: ${missing[*]},正在自动安装..."
if command -v apt-get &>/dev/null; then
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq "${missing[@]}"
elif command -v dnf &>/dev/null; then
dnf install -y "${missing[@]}"
elif command -v yum &>/dev/null; then
yum install -y "${missing[@]}"
elif command -v apk &>/dev/null; then
apk add --no-cache "${missing[@]}"
else
error "未识别的包管理器,请手动安装: ${missing[*]}"
exit 1
fi
for cmd in curl unzip openssl; do
if ! command -v "$cmd" &>/dev/null; then
error "依赖安装失败: ${cmd},请手动安装后重试"
exit 1
fi
done
log "依赖安装完成"
}
# ===== 1. 安装 Xray =====
install_xray() {
step "1/5 安装 Xray"
if command -v xray &>/dev/null || [ -x /usr/local/bin/xray ]; then
if [ -x /usr/local/bin/xray ]; then
log "Xray 已安装: $(/usr/local/bin/xray version | head -1)"
log "将更新到最新版本..."
fi
bash <(curl -fsSL https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh)
# 不用 bash <(curl ...):curl 失败时进程替换只产生空脚本,
# 外层 bash 仍返回 0,会掩盖下载失败
local installer
installer="$(mktemp)"
local url ok=0
for url in \
"https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh" \
"https://github.com/XTLS/Xray-install/raw/main/install-release.sh"
do
if curl -fsSL --max-time 60 "$url" -o "$installer" && [ -s "$installer" ]; then
ok=1
break
fi
warn "下载失败,尝试备用地址: $url"
done
if [ "$ok" -ne 1 ]; then
rm -f "$installer"
error "无法下载 Xray 安装脚本,请检查服务器网络 / DNS"
exit 1
fi
bash "$installer"
rm -f "$installer"
if [ ! -x /usr/local/bin/xray ]; then
error "Xray 安装失败:/usr/local/bin/xray 不存在"
exit 1
fi
log "Xray 安装完成: $(/usr/local/bin/xray version | head -1)"
}
@@ -471,6 +543,7 @@ main() {
[ "$MODE" = "reality" ] && log "VLESS-Reality(推荐,抗封锁)" || log "VLESS TCP(极速,无 TLS"
echo ""
ensure_deps
install_xray
generate_keys
select_reality_dest