DailyMotion/install_ql.sh

63 lines
2.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# install_ql2183.sh install QingLong v2.18.3-3 (host mode)
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
######################## 可自定义区域 ########################
QL_VERSION="2.18.3-3"
NODE_MAJOR="20"
QL_DATA_DIR="/opt/ql/data" # 仅数据放 /opt/ql
QL_PORT="5700"
##############################################################
[[ $EUID -eq 0 ]] || { echo "请用 root 或 sudo 执行"; exit 1; }
echo "▶ 允许 APT 接受 Suite 变更..."
cat >/etc/apt/apt.conf.d/99releaseinfochange <<'EOF'
Acquire::AllowReleaseInfoChange::Suite "true";
Acquire::AllowReleaseInfoChange::Version "true";
EOF
echo "▶ 刷新索引 & 安装依赖..."
apt-get update -qq
apt-get install -y curl git python3 python3-pip build-essential >/dev/null
echo "▶ 安装 Node.js $NODE_MAJOR.x..."
curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - >/dev/null
apt-get install -y nodejs >/dev/null
echo "▶ 安装 pnpm 与 QingLong..."
npm install -g pnpm@8.3.1 node-pre-gyp >/dev/null
npm install -g "@whyour/qinglong@${QL_VERSION}" >/dev/null
# 🟢 自动解析 QingLong 源码真实路径
QL_DIR="$(npm root -g)/@whyour/qinglong"
echo "▶ QingLong 源码目录: $QL_DIR"
echo "▶ 创建数据目录 $QL_DATA_DIR..."
mkdir -p "$QL_DATA_DIR"
chown -R "$(logname)":"$(logname)" "$QL_DATA_DIR"
# 🟢 如无 .env 则拷贝一份
if [[ ! -f "$QL_DIR/.env" && -f "$QL_DIR/.env.example" ]]; then
cp "$QL_DIR/.env.example" "$QL_DIR/.env"
echo "▶ 已生成 $QL_DIR/.env"
fi
echo "▶ 写入环境变量文件..."
cat >/etc/profile.d/qinglong.sh <<EOF
# >>> QingLong env
export QL_DIR="$QL_DIR"
export QL_DATA_DIR="$QL_DATA_DIR"
export QL_PORT="$QL_PORT"
export PATH="\$PATH:$(npm root -g)/../.bin"
# <<< QingLong env
EOF
chmod 644 /etc/profile.d/qinglong.sh
# 🟢 立刻生效
. /etc/profile.d/qinglong.sh
echo -e "\n✅ 安装完成!可立即运行: qinglong init"
echo " 如果要开机自启,再执行 qinglong boot 或写 systemd 均可。"