Files
clash-rules/scripts/warpgates/update-core-and-dash.sh
DaTekShaman 95230c6349 feat: Add Mihomo and TProxy setup scripts for Alpine and legacy systems
- Introduced `iptables-mihomo-setup-mark2.sh` for advanced TProxy configuration.
- Created `iptables-mihomo-setup.sh` for legacy iptables management.
- Added `dnssec-test.sh` for DNSSEC interception testing.
- Implemented `config-warpgate-alpine.sh` for comprehensive Warpgate setup.
- Developed `iptables-mihomo-setup-alpine-mark2.sh` for refined TProxy rules on Alpine.
- Added `iptables-mihomo-setup-alpine.sh` for basic TProxy setup on Alpine.
- Created `update-core-and-dash.sh` for automated updates of Mihomo core and Zashboard UI.
2026-04-11 19:32:05 +03:00

81 lines
2.5 KiB
Bash

#!/bin/sh
set -e
# Configuration
UI_URL="https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip"
BIN_DIR="/usr/local/bin"
UI_DIR="/etc/mihomo/ui/zashboard"
echo "[*] Resolving latest Alpha URL from vernesong/mihomo..."
CORE_URL=$(curl -sL "https://api.github.com/repos/vernesong/mihomo/releases/tags/Prerelease-Alpha" | grep -o 'https://[^"]*mihomo-linux-amd64-alpha-smart-[^"]*\.gz' | head -n 1)
if [ -z "$CORE_URL" ]; then
echo "[-] ERROR: Failed to resolve download URL."
exit 1
fi
echo "[+] Target URL: $CORE_URL"
# ==========================================
# ФАЗА 1: СЕТЕВЫЕ ОПЕРАЦИИ (пока жив DNS)
# ==========================================
echo "[*] Downloading Mihomo Core..."
curl -SLf -o /tmp/mihomo.gz "$CORE_URL"
if [ ! -s /tmp/mihomo.gz ]; then
echo "[-] ERROR: Downloaded core file is empty or missing!"
exit 1
fi
echo "[*] Downloading Zashboard UI..."
curl -SLf -o /tmp/zashboard.zip "$UI_URL"
if [ ! -s /tmp/zashboard.zip ]; then
echo "[-] ERROR: Downloaded UI file is empty or missing!"
exit 1
fi
# ==========================================
# ФАЗА 2: ЛОКАЛЬНЫЕ ОПЕРАЦИИ (остановка сервиса)
# ==========================================
echo "[*] Stopping mihomo service..."
rc-service mihomo stop
echo "[*] Unpacking and installing Mihomo Core..."
gzip -d -f /tmp/mihomo.gz
mv /tmp/mihomo "$BIN_DIR/mihomo"
chmod 755 "$BIN_DIR/mihomo"
chown root:root "$BIN_DIR/mihomo"
setcap 'cap_net_admin,cap_net_bind_service=+ep' "$BIN_DIR/mihomo"
echo "[*] Unpacking and installing Zashboard UI..."
# Создаем изолированную директорию для распаковки
mkdir -p /tmp/zash_temp
unzip -q -o /tmp/zashboard.zip -d /tmp/zash_temp/
# Динамически ищем, как GitHub назвал корневую папку внутри архива
EXTRACTED_DIR=$(find /tmp/zash_temp -mindepth 1 -maxdepth 1 -type d | head -n 1)
if [ -z "$EXTRACTED_DIR" ]; then
echo "[-] ERROR: Could not find extracted UI directory in the zip archive."
rc-service mihomo start
exit 1
fi
rm -rf "$UI_DIR"/*
# Копируем содержимое найденной папки
cp -r "$EXTRACTED_DIR"/* "$UI_DIR"/
chown -R root:root "$UI_DIR"
find "$UI_DIR" -type d -exec chmod 755 {} \;
find "$UI_DIR" -type f -exec chmod 644 {} \;
# Зачищаем следы
rm -rf /tmp/zashboard.zip /tmp/zash_temp
echo "[*] Starting mihomo service..."
rc-service mihomo start
echo "[+] Update completed successfully."