Compare commits
2 Commits
ed73b90ef0
...
72fefab22d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72fefab22d | ||
|
|
ee752d4988 |
@@ -127,7 +127,7 @@ if [ -z "$REPO_FILE" ]; then
|
||||
esac
|
||||
fi
|
||||
|
||||
mirror=''
|
||||
mirror='nyist'
|
||||
DRY_RUN=${DRY_RUN:-}
|
||||
REPO_ONLY=${REPO_ONLY:-0}
|
||||
NO_AUTOSTART=${NO_AUTOSTART:-0}
|
||||
|
||||
87
linux-managements/menu.sh
Normal file
87
linux-managements/menu.sh
Normal file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'; CYAN='\033[0;36m'; BOLD='\033[1m'; NC='\033[0m'
|
||||
|
||||
_NAMES=(); _DESCS=(); _URLS=()
|
||||
add() { _NAMES+=("$1"); _DESCS+=("$2"); _URLS+=("$3"); }
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════════════
|
||||
# CONFIGURATION — 在此处添加或修改脚本条目
|
||||
# 用法: add "<显示名称>" "<脚本说明>" "<脚本 URL>"
|
||||
# ════════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
add "Linux 初始化配置" \
|
||||
"配置 HTTP 代理、SSH 密钥、安装 Homebrew 及常用软件、配置 Fish Shell、同步 Dotfiles" \
|
||||
"https://git.mitsea.com/FlintyLemming/scripts-public/raw/branch/main/linux-managements/setup.sh"
|
||||
|
||||
add "安装 Docker Engine(中国大陆服务器)" \
|
||||
"自动检测发行版,经由南洋理工镜像源安装 Docker Engine、Compose、Buildx 等组件" \
|
||||
"https://git.mitsea.com/FlintyLemming/scripts-public/raw/branch/main/linux-managements/install-docker.sh"
|
||||
|
||||
add "配置 Snapper 快照" \
|
||||
"为 Btrfs 子卷配置 Snapper 自动快照,按天/周/月/年策略保留快照并启用 systemd 定时器" \
|
||||
"https://git.mitsea.com/FlintyLemming/scripts-public/raw/branch/main/linux-managements/setup-snapper.sh"
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════════════
|
||||
# 以下为脚本逻辑,无需修改
|
||||
# ════════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
draw_menu() {
|
||||
echo -e "\n${BOLD}${BLUE}╔══════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BOLD}${BLUE}║ Linux Management Scripts ║${NC}"
|
||||
echo -e "${BOLD}${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}\n"
|
||||
|
||||
local total="${#_NAMES[@]}"
|
||||
for (( i=0; i<total; i++ )); do
|
||||
echo -e " ${BOLD}${CYAN}[$((i+1))]${NC} ${BOLD}${_NAMES[$i]}${NC}"
|
||||
echo -e " ${YELLOW}${_DESCS[$i]}${NC}"
|
||||
echo
|
||||
done
|
||||
|
||||
echo -e " ${BOLD}${RED}[0]${NC} 退出\n"
|
||||
}
|
||||
|
||||
run_script() {
|
||||
local idx=$1
|
||||
local name="${_NAMES[$idx]}"
|
||||
local url="${_URLS[$idx]}"
|
||||
|
||||
echo -e "\n${GREEN}[OK]${NC} 正在执行: ${BOLD}$name${NC}"
|
||||
echo -e "${CYAN}[INFO]${NC} 来源: $url\n"
|
||||
echo -e "${BLUE}──────────────────────────────────────────────────────────────${NC}\n"
|
||||
|
||||
if command -v curl &>/dev/null; then
|
||||
bash <(curl -fsSL "$url")
|
||||
elif command -v wget &>/dev/null; then
|
||||
bash <(wget -qO- "$url")
|
||||
else
|
||||
echo -e "${RED}[ERR]${NC} 未找到 curl 或 wget,无法下载脚本。" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local total="${#_NAMES[@]}"
|
||||
|
||||
while true; do
|
||||
draw_menu
|
||||
read -rp "请选择要执行的脚本 [0-$total]: " choice
|
||||
|
||||
if [[ "$choice" == "0" ]]; then
|
||||
echo -e "\n${CYAN}[INFO]${NC} 已退出。\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [[ "$choice" =~ ^[0-9]+$ ]] || (( choice < 1 || choice > total )); then
|
||||
echo -e "\n${RED}[ERR]${NC} 无效选项,请输入 0 到 $total 之间的数字。\n"
|
||||
continue
|
||||
fi
|
||||
|
||||
run_script $(( choice - 1 ))
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
main
|
||||
@@ -296,20 +296,9 @@ install_docker() {
|
||||
if command -v docker &>/dev/null; then
|
||||
info "Docker already installed ($(docker --version)), skipping"
|
||||
else
|
||||
echo ""
|
||||
echo -e "Use a ${BOLD}domestic mirror${NC} for Docker installation? ${YELLOW}(recommended in China)${NC}"
|
||||
read -rp "Use mirror? [y/N] " use_mirror
|
||||
case "$use_mirror" in
|
||||
[Yy]*)
|
||||
curl -fsSL https://git.mitsea.com/FlintyLemming/scripts-public/raw/branch/main/linux-managements/install-docker.sh \
|
||||
-o /tmp/install-docker.sh
|
||||
sudo sh /tmp/install-docker.sh --mirror nyist
|
||||
;;
|
||||
*)
|
||||
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
|
||||
sudo sh /tmp/get-docker.sh
|
||||
;;
|
||||
esac
|
||||
curl -fsSL https://git.mitsea.com/FlintyLemming/scripts-public/raw/branch/main/linux-managements/install-docker.sh \
|
||||
-o /tmp/install-docker.sh
|
||||
sudo sh /tmp/install-docker.sh
|
||||
success "Docker installed"
|
||||
fi
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user