Update install.sh
This commit is contained in:
29
install.sh
29
install.sh
@@ -2,7 +2,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# 颜色配置
|
# 🎨 颜色配置
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
RED='\033[1;31m'
|
RED='\033[1;31m'
|
||||||
GREEN='\033[1;32m'
|
GREEN='\033[1;32m'
|
||||||
@@ -12,21 +12,20 @@ CYAN='\033[1;36m'
|
|||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# 基本信息
|
# 📦 基本信息
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
VERSION="v24"
|
|
||||||
REPO="QuickWrt/QuickWrt"
|
REPO="QuickWrt/QuickWrt"
|
||||||
ASSET="QuickWrt.tar.gz"
|
ASSET="QuickWrt.tar.gz"
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# 工具函数
|
# 🧰 工具函数
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
log() { echo -e "${BLUE}ℹ️ $*${RESET}"; }
|
log() { echo -e "${BLUE}ℹ️ $*${RESET}"; }
|
||||||
ok() { echo -e "${GREEN}✅ $*${RESET}"; }
|
ok() { echo -e "${GREEN}✅ $*${RESET}"; }
|
||||||
err() { echo -e "${RED}❌ $*${RESET}" && exit 1; }
|
err() { echo -e "${RED}❌ $*${RESET}" && exit 1; }
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# 获取最新 release tag
|
# 🔍 获取最新 release tag
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
get_latest_release() {
|
get_latest_release() {
|
||||||
curl -s "https://api.github.com/repos/${REPO}/releases/latest" \
|
curl -s "https://api.github.com/repos/${REPO}/releases/latest" \
|
||||||
@@ -34,7 +33,7 @@ get_latest_release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# 菜单函数
|
# 🧭 菜单函数
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
show_menu() {
|
show_menu() {
|
||||||
local title="$1"
|
local title="$1"
|
||||||
@@ -53,7 +52,7 @@ show_menu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# 交互选择
|
# 💡 交互选择模式
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
interactive_mode() {
|
interactive_mode() {
|
||||||
log "进入交互模式选择编译参数..."
|
log "进入交互模式选择编译参数..."
|
||||||
@@ -71,7 +70,6 @@ interactive_mode() {
|
|||||||
BUILD_MODE="${mode_options[$((mode_choice-1))]}"
|
BUILD_MODE="${mode_options[$((mode_choice-1))]}"
|
||||||
|
|
||||||
echo -e "\n${GREEN}✅ 已选择:${RESET}"
|
echo -e "\n${GREEN}✅ 已选择:${RESET}"
|
||||||
echo -e " • 版本号 : ${CYAN}${VERSION}${RESET}"
|
|
||||||
echo -e " • 架构 : ${CYAN}${TARGET_ARCH}${RESET}"
|
echo -e " • 架构 : ${CYAN}${TARGET_ARCH}${RESET}"
|
||||||
echo -e " • 编译模式 : ${CYAN}${BUILD_MODE}${RESET}\n"
|
echo -e " • 编译模式 : ${CYAN}${BUILD_MODE}${RESET}\n"
|
||||||
|
|
||||||
@@ -79,15 +77,15 @@ interactive_mode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# 执行 build.sh
|
# ⚙️ 执行 build.sh
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
run_build() {
|
run_build() {
|
||||||
log "执行: ./build.sh ${VERSION} ${TARGET_ARCH} ${BUILD_MODE}"
|
log "执行: ./build.sh ${TARGET_ARCH} ${BUILD_MODE}"
|
||||||
./build.sh "${VERSION}" "${TARGET_ARCH}" "${BUILD_MODE}"
|
bash ./build.sh "${TARGET_ARCH}" "${BUILD_MODE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# 主逻辑
|
# 🚀 主逻辑
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
main() {
|
main() {
|
||||||
log "检查系统依赖..."
|
log "检查系统依赖..."
|
||||||
@@ -107,15 +105,14 @@ main() {
|
|||||||
mkdir QuickWrt
|
mkdir QuickWrt
|
||||||
tar -xzf "${ASSET}" -C QuickWrt || err "解压失败"
|
tar -xzf "${ASSET}" -C QuickWrt || err "解压失败"
|
||||||
|
|
||||||
# 进入构建目录
|
|
||||||
cd QuickWrt || err "进入 QuickWrt 失败"
|
cd QuickWrt || err "进入 QuickWrt 失败"
|
||||||
|
|
||||||
# 如果解压后有一个顶层目录,则进入该目录
|
# 如果解压后有一个顶层目录则进入
|
||||||
if [ $(ls -1 | wc -l) -eq 1 ] && [ -d "$(ls -1)" ]; then
|
if [ $(ls -1 | wc -l) -eq 1 ] && [ -d "$(ls -1)" ]; then
|
||||||
log "检测到顶层目录,进入: $(ls -1)"
|
log "检测到顶层目录,进入: $(ls -1)"
|
||||||
cd "$(ls -1)" || err "进入解压目录失败"
|
cd "$(ls -1)" || err "进入解压目录失败"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 检查必要文件
|
# 检查必要文件
|
||||||
[ -f "./build.sh" ] || err "未找到构建脚本: build.sh"
|
[ -f "./build.sh" ] || err "未找到构建脚本: build.sh"
|
||||||
[ -d "./scripts" ] || err "未找到 scripts 目录"
|
[ -d "./scripts" ] || err "未找到 scripts 目录"
|
||||||
@@ -123,7 +120,7 @@ main() {
|
|||||||
chmod +x ./build.sh
|
chmod +x ./build.sh
|
||||||
chmod +x ./scripts/*.sh 2>/dev/null || log "为 scripts 目录下的脚本设置执行权限"
|
chmod +x ./scripts/*.sh 2>/dev/null || log "为 scripts 目录下的脚本设置执行权限"
|
||||||
|
|
||||||
# 交互模式选择
|
# 进入交互模式
|
||||||
interactive_mode
|
interactive_mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user