Update mermaids.sh

This commit is contained in:
Dan 2026-04-17 00:02:12 +08:00
parent ff47e4ea57
commit 0a97c1f04a

View File

@ -122,50 +122,42 @@ cat > /tmp/mermaid-install.sh <<'EOF'
#!/bin/bash
set -euo pipefail
# === Define functions FIRST ===
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log() { echo -e "${GREEN}[$(date +%H:%M:%S)]${NC} $1"; }
warn() { echo -e "${YELLOW}[$(date +%H:%M:%S)]${NC} $1"; }
die() { echo -e "${RED}[$(date +%H:%M:%S)]${NC} $1"; exit 1; }
PORT="${1:-80}"
# 1. Update & install Caddy + deps
# log "Setting up apt with public DNS..."
# === Now run operations ===
log "Setting up apt with public DNS..."
mkdir -p /etc/apt/apt.conf.d
cat > /etc/apt/apt.conf.d/99-dns <<'APTCONF'
Acquire::Dns "1.1.1.1";
APTCONF
# mkdir -p /etc/apt/apt.conf.d
# cat > /etc/apt/apt.conf.d/99-dns <<'EOF'
# Acquire::Dns "1.1.1.1";
# EOF
cat > /etc/resolv.conf <<'RESOLVCONF'
nameserver 1.1.1.1
RESOLVCONF
# # Ensure resolv.conf uses a plain DNS for fallback
# cat > /etc/resolv.conf <<'EOF'
# nameserver 1.1.1.1
# EOF
log "Updating package lists..."
if grep -q "deb debianmain" /etc/apt/sources.list; then
sed -i 's/deb \(.*\) main/deb \1 main non-free non-free-firmware/' /etc/apt/sources.list
fi
# log "Updating package lists..."
# # Enable non-free for ufw (Debian 12 requirement)
# if grep -q "deb debianmain" /etc/apt/sources.list; then
# sed -i 's/deb \(.*\) main/deb \1 main non-free non-free-firmware/' /etc/apt/sources.list
# fi
# apt-get update -o Acquire::Retries=3
# rm /etc/resolv.conf /etc/apt/apt.conf.d/99-dns 2>/dev/null
apt-get update -o Acquire::Retries=3 || {
warn "apt-get update failed — checking DNS..."
cat /etc/resolv.conf
exit 1
}
log "Fixing Debian CDN routing..."
# Try AdGuard's CDN node first
# if curl -sf http://146.75.22.132/debian/dists/bookworm/Release >/dev/null 2>&1; then
sed -i "s|http://deb.debian.org|http://146.75.22.132|g" /etc/apt/sources.list
log "Using Fastly node: 146.75.22.132"
# # Fallback to Cloudflare's CDN node
# elif curl -sf http://151.101.2.132/debian/dists/bookworm/Release >/dev/null 2>&1; then
# sed -i "s|http://deb.debian.org|http://151.101.2.132|g" /etc/apt/sources.list
# log "Using Fastly node: 151.101.2.132"
# else
# warn "Both Fastly nodes unreachable — trying direct domain (may fail)"
# fi
apt-get update -o Acquire::Retries=3
# Clean up temporary DNS config
rm -f /etc/resolv.conf /etc/apt/apt.conf.d/99-dns 2>/dev/null
log "Installing dependencies..."
apt-get install -y -qq \