交互隐藏

This commit is contained in:
James 2025-01-21 12:56:52 +08:00
parent 3e19b74497
commit af8ed99ba4
2 changed files with 60 additions and 72 deletions

View File

@ -202,7 +202,6 @@ update_system() {
# 定义支持的操作系统类型 # 定义支持的操作系统类型
SUPPORTED_OS=("ubuntu" "debian" "linuxmint" "elementary" "pop" "centos" "rhel" "fedora" "rocky" "almalinux" "openeuler" "opensuse" "sles" "arch" "manjaro" "alpine" "gentoo" "cloudlinux") SUPPORTED_OS=("ubuntu" "debian" "linuxmint" "elementary" "pop" "centos" "rhel" "fedora" "rocky" "almalinux" "openeuler" "opensuse" "sles" "arch" "manjaro" "alpine" "gentoo" "cloudlinux")
# 安装依赖
install_dependencies() { install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}" echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
@ -224,50 +223,44 @@ install_dependencies() {
fi fi
case "${os_type,,}" in case "${os_type,,}" in
gentoo) debian|ubuntu)
install_cmd="emerge" export DEBIAN_FRONTEND=noninteractive # 禁用交互
for dep in "${dependencies[@]}"; do install_cmd="apt-get install -yq"
if ! emerge -p $dep &>/dev/null; then sudo apt-get update -yq
echo -e "${YELLOW}正在安装 $dep...${NC}" ;;
if ! sudo $install_cmd $dep; then centos|rhel|fedora)
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}" install_cmd="dnf install -y"
fi sudo dnf makecache
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;; ;;
alpine) alpine)
install_cmd="apk add" install_cmd="apk add --no-cache"
for dep in "${dependencies[@]}"; do ;;
if ! command -v "$dep" &> /dev/null; then gentoo)
echo -e "${YELLOW}正在安装 $dep...${NC}" install_cmd="emerge --quiet"
if ! sudo $install_cmd "$dep"; then ;;
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}" arch|manjaro)
fi install_cmd="pacman -S --noconfirm"
else sudo pacman -Sy --noconfirm
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;; ;;
*) *)
install_cmd="apt-get install -yq" echo -e "${RED}未知的包管理器。请手动安装依赖项。${NC}"
export DEBIAN_FRONTEND=noninteractive return 1
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;; ;;
esac esac
# 安装依赖项
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}" echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
} }
# 获取IP地址和ISP信息 # 获取IP地址和ISP信息

View File

@ -223,53 +223,48 @@ install_dependencies() {
fi fi
case "${os_type,,}" in case "${os_type,,}" in
gentoo) debian|ubuntu)
install_cmd="emerge --quiet" export DEBIAN_FRONTEND=noninteractive # 禁用交互
for dep in "${dependencies[@]}"; do install_cmd="apt-get install -yq"
if ! emerge -p "$dep" &>/dev/null; then sudo apt-get update -yq
echo -e "${YELLOW}正在安装 $dep...${NC}" ;;
if ! sudo $install_cmd "$dep"; then centos|rhel|fedora)
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}" install_cmd="dnf install -y"
fi sudo dnf makecache
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;; ;;
alpine) alpine)
install_cmd="apk add --no-cache" install_cmd="apk add --no-cache"
for dep in "${dependencies[@]}"; do ;;
if ! command -v "$dep" &>/dev/null; then gentoo)
echo -e "${YELLOW}正在安装 $dep...${NC}" install_cmd="emerge --quiet"
if ! sudo $install_cmd "$dep"; then ;;
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}" arch|manjaro)
fi install_cmd="pacman -S --noconfirm"
else sudo pacman -Sy --noconfirm
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;; ;;
*) *)
install_cmd="apt-get install -yq" echo -e "${RED}未知的包管理器。请手动安装依赖项。${NC}"
export DEBIAN_FRONTEND=noninteractive return 1
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;; ;;
esac esac
# 安装依赖项
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}" echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
} }
# 获取IP地址和ISP信息 # 获取IP地址和ISP信息
ip_address_and_isp() { ip_address_and_isp() {
ipv4_address=$(curl -s --max-time 5 ipv4.ip.sb) ipv4_address=$(curl -s --max-time 5 ipv4.ip.sb)