mirror of
https://github.com/everett7623/nodeloc_vps_test.git
synced 2024-11-10 10:05:18 +00:00
Update Nlbench_beta.sh
This commit is contained in:
parent
6dfa75f038
commit
ebf7e3df30
@ -113,10 +113,17 @@ detect_os() {
|
|||||||
. /etc/lsb-release
|
. /etc/lsb-release
|
||||||
os_type=$DISTRIB_ID
|
os_type=$DISTRIB_ID
|
||||||
os_version=$DISTRIB_RELEASE
|
os_version=$DISTRIB_RELEASE
|
||||||
|
elif [ -f /etc/redhat-release ]; then
|
||||||
|
os_type=$(cat /etc/redhat-release | cut -d ' ' -f 1)
|
||||||
|
os_version=$(cat /etc/redhat-release | sed 's/.*release \([0-9\.]*\).*/\1/')
|
||||||
|
elif [ -f /etc/gentoo-release ]; then
|
||||||
|
os_type="gentoo"
|
||||||
|
os_version=$(cat /etc/gentoo-release | cut -d ' ' -f 5)
|
||||||
else
|
else
|
||||||
echo -e "${RED}无法检测操作系统类型和版本。${NC}"
|
os_type=$(uname -s)
|
||||||
return 1
|
os_version=$(uname -r)
|
||||||
fi
|
fi
|
||||||
|
os_type=$(echo "$os_type" | tr '[:upper:]' '[:lower:]')
|
||||||
echo -e "${YELLOW}检测到的系统: $os_type $os_version${NC}"
|
echo -e "${YELLOW}检测到的系统: $os_type $os_version${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,15 +131,14 @@ detect_os() {
|
|||||||
update_system() {
|
update_system() {
|
||||||
detect_os || return 1
|
detect_os || return 1
|
||||||
|
|
||||||
# 根据操作系统类型选择更新命令
|
|
||||||
case "${os_type,,}" in
|
case "${os_type,,}" in
|
||||||
ubuntu|debian|linuxmint|elementary|pop)
|
ubuntu|debian|linuxmint|elementary|pop)
|
||||||
update_cmd="apt-get update"
|
update_cmd="apt-get update"
|
||||||
upgrade_cmd="apt-get upgrade -y"
|
upgrade_cmd="apt-get upgrade -y"
|
||||||
install_cmd="apt-get install -y"
|
install_cmd="apt-get install -y"
|
||||||
;;
|
;;
|
||||||
fedora|centos|rhel|ol|rocky|almalinux)
|
centos|rhel|fedora|rocky|almalinux|openeuler)
|
||||||
if [ "${os_version%%.*}" -ge 22 ] || [ "${os_version%%.*}" -ge 8 ]; then
|
if command -v dnf &>/dev/null; then
|
||||||
update_cmd="dnf check-update"
|
update_cmd="dnf check-update"
|
||||||
upgrade_cmd="dnf upgrade -y"
|
upgrade_cmd="dnf upgrade -y"
|
||||||
install_cmd="dnf install -y"
|
install_cmd="dnf install -y"
|
||||||
@ -157,6 +163,16 @@ update_system() {
|
|||||||
upgrade_cmd="apk upgrade"
|
upgrade_cmd="apk upgrade"
|
||||||
install_cmd="apk add"
|
install_cmd="apk add"
|
||||||
;;
|
;;
|
||||||
|
gentoo)
|
||||||
|
update_cmd="emerge --sync"
|
||||||
|
upgrade_cmd="emerge -uDN @world"
|
||||||
|
install_cmd="emerge"
|
||||||
|
;;
|
||||||
|
cloudlinux)
|
||||||
|
update_cmd="yum check-update"
|
||||||
|
upgrade_cmd="yum upgrade -y"
|
||||||
|
install_cmd="yum install -y"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "${RED}不支持的 Linux 发行版: $os_type${NC}"
|
echo -e "${RED}不支持的 Linux 发行版: $os_type${NC}"
|
||||||
return 1
|
return 1
|
||||||
@ -189,6 +205,20 @@ install_dependencies() {
|
|||||||
# 安装依赖
|
# 安装依赖
|
||||||
local dependencies=("curl" "wget" "iperf3")
|
local dependencies=("curl" "wget" "iperf3")
|
||||||
|
|
||||||
|
case "${os_type,,}" in
|
||||||
|
gentoo)
|
||||||
|
for dep in "${dependencies[@]}"; do
|
||||||
|
if ! emerge -p $dep &>/dev/null; then
|
||||||
|
echo -e "${YELLOW}正在安装 $dep...${NC}"
|
||||||
|
if ! sudo emerge $dep; then
|
||||||
|
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}$dep 已安装。${NC}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
for dep in "${dependencies[@]}"; do
|
for dep in "${dependencies[@]}"; do
|
||||||
if ! command -v "$dep" &> /dev/null; then
|
if ! command -v "$dep" &> /dev/null; then
|
||||||
echo -e "${YELLOW}正在安装 $dep...${NC}"
|
echo -e "${YELLOW}正在安装 $dep...${NC}"
|
||||||
@ -199,6 +229,8 @@ install_dependencies() {
|
|||||||
echo -e "${GREEN}$dep 已安装。${NC}"
|
echo -e "${GREEN}$dep 已安装。${NC}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
|
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
|
||||||
clear
|
clear
|
||||||
|
Loading…
Reference in New Issue
Block a user