's'
This commit is contained in:
68
d2ypp2/live-platform/scripts/doctor.sh
Normal file
68
d2ypp2/live-platform/scripts/doctor.sh
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
# 一键体检:网络 / 端口 / adb / ffmpeg / docker / 服务状态(模块化输出)
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
REPO="$(cd "$ROOT/.." && pwd)"
|
||||
# shellcheck source=/dev/null
|
||||
source "$ROOT/scripts/lib/common.sh"
|
||||
|
||||
echo "=== Live Platform Doctor ==="
|
||||
echo "arch: $(detect_arch)"
|
||||
echo "hostname: $(hostname -f 2>/dev/null || hostname)"
|
||||
|
||||
section() { echo ""; echo "--- $1 ---"; }
|
||||
|
||||
section "loopback / DNS"
|
||||
ping -c1 -W2 127.0.0.1 >/dev/null 2>&1 && echo "ping 127.0.0.1: ok" || echo "ping 127.0.0.1: fail"
|
||||
getent hosts live.local >/dev/null 2>&1 && echo "live.local resolves: yes" || echo "live.local resolves: (optional mdns)"
|
||||
|
||||
section "config"
|
||||
if [[ -f /opt/live/config/system.json ]]; then
|
||||
echo "system.json: present"
|
||||
else
|
||||
echo "system.json: MISSING (run install-core)"
|
||||
fi
|
||||
if [[ -f /opt/live/generated/system-stack.env ]]; then
|
||||
echo "generated env: present"
|
||||
else
|
||||
echo "generated env: missing"
|
||||
fi
|
||||
|
||||
section "ports (LISTEN)"
|
||||
command -v ss >/dev/null 2>&1 && ss -tlnp 2>/dev/null | head -n 40 || netstat -tlnp 2>/dev/null | head -n 40 || true
|
||||
|
||||
section "adb"
|
||||
if command -v adb >/dev/null 2>&1; then
|
||||
adb devices -l || true
|
||||
else
|
||||
echo "adb not installed"
|
||||
fi
|
||||
|
||||
section "ffmpeg"
|
||||
command -v ffmpeg >/dev/null 2>&1 && ffmpeg -version | head -n1 || echo "ffmpeg missing"
|
||||
|
||||
section "docker"
|
||||
if command -v docker >/dev/null 2>&1; then
|
||||
docker info >/dev/null 2>&1 && echo "docker: daemon ok" || echo "docker: daemon unreachable"
|
||||
else
|
||||
echo "docker not installed"
|
||||
fi
|
||||
|
||||
section "proxy hint (ShellCrash)"
|
||||
if [[ -d /etc/ShellCrash ]]; then
|
||||
echo "ShellCrash dir: /etc/ShellCrash"
|
||||
else
|
||||
echo "ShellCrash dir: not found"
|
||||
fi
|
||||
|
||||
if [[ -f "$REPO/web.py" ]] && command -v curl >/dev/null 2>&1; then
|
||||
section "API"
|
||||
PORT="${PORT:-8001}"
|
||||
curl -sS -m 3 "http://127.0.0.1:${PORT}/health" && echo "" || echo "health check failed on :$PORT"
|
||||
section "Port 80 (live-edge / Caddy)"
|
||||
systemctl is-active live-edge.service 2>/dev/null || echo "live-edge.service: inactive"
|
||||
curl -sS -m 5 -o /dev/null -w "GET http://127.0.0.1/ → http_code=%{http_code}\n" "http://127.0.0.1/" || echo "curl :80 failed"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Doctor finished ==="
|
||||
42
d2ypp2/live-platform/scripts/install-core.sh
Normal file
42
d2ypp2/live-platform/scripts/install-core.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# 幂等:同步配置中心默认 JSON → /opt/live/config,生成 system-stack.env,安装 Hub(无业务模块)
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
REPO="$(cd "$ROOT/.." && pwd)"
|
||||
# shellcheck source=/dev/null
|
||||
source "$ROOT/scripts/lib/common.sh"
|
||||
|
||||
ARCH="$(detect_arch)"
|
||||
echo "[live-platform] install-core arch=$ARCH"
|
||||
|
||||
ensure_live_dirs
|
||||
|
||||
if [[ ! -f /opt/live/config/system.json ]]; then
|
||||
cp -a "$ROOT/config/defaults/system.json" /opt/live/config/system.json
|
||||
fi
|
||||
if [[ ! -f /opt/live/config/network.json ]]; then
|
||||
cp -a "$ROOT/config/defaults/network.json" /opt/live/config/network.json
|
||||
fi
|
||||
if command -v rsync >/dev/null 2>&1; then
|
||||
rsync -a --ignore-existing "$ROOT/config/defaults/services/" /opt/live/config/services/
|
||||
rsync -a --ignore-existing "$ROOT/config/defaults/business/" /opt/live/config/business/
|
||||
else
|
||||
cp -n "$ROOT/config/defaults/services/"*.json /opt/live/config/services/ 2>/dev/null || true
|
||||
cp -n "$ROOT/config/defaults/business/"*.json /opt/live/config/business/ 2>/dev/null || true
|
||||
fi
|
||||
|
||||
export LIVE_CONFIG_ROOT="${LIVE_CONFIG_ROOT:-/opt/live/config}"
|
||||
python3 "$ROOT/tools/render_stack_env.py" /opt/live/generated/system-stack.env
|
||||
|
||||
if [[ -n "${LINK_REPO_CONFIG:-}" ]]; then
|
||||
mkdir -p "$REPO/config"
|
||||
ln -sf /opt/live/generated/system-stack.env "$REPO/config/system-stack.env"
|
||||
fi
|
||||
|
||||
if [[ -x "$REPO/scripts/linux/install_hub.sh" ]]; then
|
||||
bash "$REPO/scripts/linux/install_hub.sh" "$@"
|
||||
else
|
||||
echo "[live-platform] WARN: scripts/linux/install_hub.sh missing, skip hub packages"
|
||||
fi
|
||||
|
||||
echo "[live-platform] install-core done. Env: /opt/live/generated/system-stack.env"
|
||||
16
d2ypp2/live-platform/scripts/install-live.sh
Normal file
16
d2ypp2/live-platform/scripts/install-live.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# 幂等:仅无人直播业务模块(与 install-core 解耦)
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
REPO="$(cd "$ROOT/.." && pwd)"
|
||||
|
||||
if [[ -x "$REPO/scripts/linux/install_business.sh" ]]; then
|
||||
bash "$REPO/scripts/linux/install_business.sh" "$@"
|
||||
else
|
||||
echo "[live-platform] ERROR: scripts/linux/install_business.sh not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p /opt/live/business/douyinyoutube
|
||||
touch /opt/live/business/douyinyoutube/.installed
|
||||
echo "[live-platform] install-live done"
|
||||
29
d2ypp2/live-platform/scripts/lib/common.sh
Normal file
29
d2ypp2/live-platform/scripts/lib/common.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
# shellcheck shell=bash
|
||||
# 被 install-core / install-live / doctor 引用;禁止写业务逻辑,仅路径与权限。
|
||||
|
||||
live_platform_root() {
|
||||
local here
|
||||
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
printf '%s\n' "$here"
|
||||
}
|
||||
|
||||
repo_root() {
|
||||
local lp
|
||||
lp="$(live_platform_root)"
|
||||
cd "$lp/.." && pwd
|
||||
}
|
||||
|
||||
detect_arch() {
|
||||
case "$(uname -m)" in
|
||||
aarch64|arm64) echo "arm64" ;;
|
||||
x86_64|amd64) echo "amd64" ;;
|
||||
*) echo "generic" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
ensure_live_dirs() {
|
||||
sudo mkdir -p /opt/live/config/services /opt/live/config/business \
|
||||
/opt/live/generated /opt/live/state /opt/live/logs /opt/live/templates 2>/dev/null || \
|
||||
mkdir -p /opt/live/config/services /opt/live/config/business \
|
||||
/opt/live/generated /opt/live/state /opt/live/logs /opt/live/templates
|
||||
}
|
||||
Reference in New Issue
Block a user