mirror of
https://github.com/everett7623/nodeloc_vps_test.git
synced 2024-12-28 01:05:19 +00:00
Update Nlbench_beta.sh
This commit is contained in:
parent
ebd773fe86
commit
76758cecac
@ -40,27 +40,48 @@ fi
|
||||
|
||||
# 更新系统并安装依赖
|
||||
install_dependencies() {
|
||||
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
|
||||
echo -e "${YELLOW}正在更新系统并安装必要的依赖项...${NC}"
|
||||
|
||||
local package_manager
|
||||
local update_cmd
|
||||
local install_cmd
|
||||
|
||||
if command -v apt &>/dev/null; then
|
||||
package_manager="apt-get"
|
||||
update_cmd="update"
|
||||
install_cmd="install -y"
|
||||
elif command -v dnf &>/dev/null; then
|
||||
package_manager="dnf"
|
||||
update_cmd="check-update"
|
||||
install_cmd="install -y"
|
||||
elif command -v yum &>/dev/null; then
|
||||
package_manager="yum"
|
||||
update_cmd="check-update"
|
||||
install_cmd="install -y"
|
||||
elif command -v apk &>/dev/null; then
|
||||
package_manager="apk"
|
||||
update_cmd="update"
|
||||
install_cmd="add"
|
||||
else
|
||||
echo -e "${RED}不支持的Linux发行版${NC}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 更新系统
|
||||
echo -e "${YELLOW}正在更新系统...${NC}"
|
||||
if update_system; then
|
||||
if sudo $package_manager $update_cmd; then
|
||||
echo -e "${GREEN}系统更新完成。${NC}"
|
||||
[ "$package_manager" != "apk" ] && sudo $package_manager upgrade -y
|
||||
else
|
||||
echo -e "${RED}系统更新失败。继续安装依赖项。${NC}"
|
||||
fi
|
||||
|
||||
# 安装依赖
|
||||
local dependencies=(
|
||||
"curl"
|
||||
"wget"
|
||||
"iperf3"
|
||||
)
|
||||
local dependencies=("curl" "wget" "iperf3")
|
||||
|
||||
for dep in "${dependencies[@]}"; do
|
||||
if ! command -v "$dep" &> /dev/null; then
|
||||
echo -e "${YELLOW}正在安装 $dep...${NC}"
|
||||
if ! install_package "$dep"; then
|
||||
if ! sudo $package_manager $install_cmd "$dep"; then
|
||||
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
|
||||
fi
|
||||
else
|
||||
@ -72,41 +93,6 @@ install_dependencies() {
|
||||
clear
|
||||
}
|
||||
|
||||
# 更新系统
|
||||
update_system() {
|
||||
if command -v apt &>/dev/null; then
|
||||
sudo apt-get update && sudo apt-get upgrade -y
|
||||
elif command -v dnf &>/dev/null; then
|
||||
sudo dnf check-update && sudo dnf upgrade -y
|
||||
elif command -v yum &>/dev/null; then
|
||||
sudo yum check-update && sudo yum upgrade -y
|
||||
elif command -v apk &>/dev/null; then
|
||||
sudo apk update && sudo apk upgrade
|
||||
else
|
||||
echo -e "${RED}不支持的Linux发行版${NC}"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# 安装包
|
||||
install_package() {
|
||||
local package=$1
|
||||
if command -v apt &>/dev/null; then
|
||||
sudo apt-get install -y "$package"
|
||||
elif command -v dnf &>/dev/null; then
|
||||
sudo dnf install -y "$package"
|
||||
elif command -v yum &>/dev/null; then
|
||||
sudo yum install -y "$package"
|
||||
elif command -v apk &>/dev/null; then
|
||||
sudo apk add "$package"
|
||||
else
|
||||
echo -e "${RED}不支持的Linux发行版${NC}"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# 获取IP地址和ISP信息
|
||||
ip_address_and_isp() {
|
||||
ipv4_address=$(curl -s --max-time 5 ipv4.ip.sb)
|
||||
|
Loading…
Reference in New Issue
Block a user