Skip to content

Commit

Permalink
Update vps_scripts.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
everett7623 authored Jun 25, 2024
1 parent 590e884 commit a9060a2
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions vps_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,45 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi

# 检查当前用户是否具有 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
echo "请使用具有 sudo 权限的用户运行此脚本。"
exit 1
fi

# 在需要时获取 sudo 权限
sudo -v >/dev/null 2>&1 || { echo "无法获取 sudo 权限,退出脚本。"; exit 1; }

# 检查并安装依赖
echo "检查并安装必要的依赖项..."

# 检查和安装 curl
if ! command -v curl &> /dev/null; then
echo "curl 未安装,正在安装..."
sudo apt-get update && sudo apt-get install -y curl
else
echo "curl 已安装"
fi

# 检查和安装 wget
if ! command -v wget &> /dev/null; then
echo "wget 未安装,正在安装..."
sudo apt-get update && sudo apt-get install -y wget
else
echo "wget 已安装"
fi

# 检查 bash(一般来说不需要安装,因为通常是系统默认的 shell)
if ! command -v bash &> /dev/null; then
echo "bash 未安装,正在安装..."
sudo apt-get update && sudo apt-get install -y bash
else
echo "bash 已安装"
fi

echo "依赖项安装完成。"

# 获取IP地址
ip_address() {
ipv4_address=$(curl -s --max-time 5 ipv4.ip.sb)
Expand Down Expand Up @@ -170,45 +209,6 @@ echo ""
echo -e "${YELLOW}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""

# 检查当前用户是否具有 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
echo "请使用具有 sudo 权限的用户运行此脚本。"
exit 1
fi

# 在需要时获取 sudo 权限
sudo -v >/dev/null 2>&1 || { echo "无法获取 sudo 权限,退出脚本。"; exit 1; }

# 检查并安装依赖
echo "检查并安装必要的依赖项..."

# 检查和安装 curl
if ! command -v curl &> /dev/null; then
echo "curl 未安装,正在安装..."
sudo apt-get update && sudo apt-get install -y curl
else
echo "curl 已安装"
fi

# 检查和安装 wget
if ! command -v wget &> /dev/null; then
echo "wget 未安装,正在安装..."
sudo apt-get update && sudo apt-get install -y wget
else
echo "wget 已安装"
fi

# 检查 bash(一般来说不需要安装,因为通常是系统默认的 shell)
if ! command -v bash &> /dev/null; then
echo "bash 未安装,正在安装..."
sudo apt-get update && sudo apt-get install -y bash
else
echo "bash 已安装"
fi

echo "依赖项安装完成。"

# 主菜单
while true; do
echo ""
Expand Down

0 comments on commit a9060a2

Please sign in to comment.