From c22973eeaa3086ea4732db61dfba8cc267e1f7c1 Mon Sep 17 00:00:00 2001 From: Lsmoisu <114275920+Lsmoisu@users.noreply.github.com> Date: Sat, 17 May 2025 23:05:14 +0800 Subject: [PATCH] Update vps_manager.sh --- vps_manager.sh | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/vps_manager.sh b/vps_manager.sh index 9059192..9eaee05 100644 --- a/vps_manager.sh +++ b/vps_manager.sh @@ -630,6 +630,47 @@ while true; do continue fi + # 下载启动脚本 + echo "正在从远程地址下载启动脚本..." + script_url="https://github.com/Lsmoisu/Toolbox/raw/refs/heads/main/enablesshandcreatesocks5.sh" + if ! command -v curl &> /dev/null; then + echo "curl 未安装,尝试安装..." + if command -v apt-get &> /dev/null; then + sudo apt-get update && sudo apt-get install -y curl + elif command -v yum &> /dev/null; then + sudo yum install -y curl + else + echo "无法安装 curl,请手动安装后重试。" + echo "按任意键返回菜单..." + read -e -r -n 1 + continue + fi + fi + + # 使用 -L 参数跟随重定向,-sS 减少输出,-f 失败时返回错误码 + if curl -L -sS -f -o startup-script.sh "$script_url"; then + echo "启动脚本下载成功!" + # 检查文件是否为空 + if [ -s startup-script.sh ]; then + echo "脚本内容非空,下载验证通过。" + chmod +x startup-script.sh + else + echo "错误:下载的脚本文件为空,请检查URL内容或网络连接。" + rm -f startup-script.sh + echo "按任意键返回菜单..." + read -e -r -n 1 + continue + fi + else + echo "启动脚本下载失败,请检查网络连接或URL是否正确。" + echo "错误信息:" + curl -L -sS "$script_url" -o /dev/null -w "%{http_code}\n" + rm -f startup-script.sh + echo "按任意键返回菜单..." + read -e -r -n 1 + continue + fi + # 选择地区选择方式 while true; do show_zone_selection_method @@ -763,7 +804,8 @@ while true; do --zone="$zone" \ --machine-type=e2-micro \ --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default \ - --metadata=ssh-keys=root:ssh-rsa\ AAAAB3NzaC1yc2EAAAADAQABAAABgQDVw/Lamb8wHXeLgCKGbumrocMvq+a6goVFBAuhYk/TVUoislrO1SrrH5YMFc7aQMZNP/mbubirIck8h0wT8hiU070OHO7HuaAyIGgFh4icIX/m7znhvWteG/evxJUN95ZWm4bk+UmGUbbAO4BkSEGub/ENJ3RGR9eJuDabgMha5fyzl9J9sm6jDeXVyGtLOy9NkYYHo/J0kUAwK1YOQ88rAXIhsJ04qsH7256VAdo6enO39Y0RG4NhK3hlRYP46f8NWyCaJFbcz4tpbHNdG9Xbqg7j/RSn7tO5bpB283m/wsZR7kM28x9dzyojJJYycEn9CTUzBjxcBBuKNa57Y+eoBo7q2KXx13ziMvO5k7Bl8GXknl0uguf49hjbPS95CThns+sqz7G3Px8a79BJ1rHEewlmMMJUa/kRY+NAcum0nVkWzZIpR6I2KWMP+8OaJLj97vIHgGydRP8y4I6IiiZBlOlshNJ3iI/XxsSWjWjdWxSHUZtHj4L1IaxclrX+QtU=\ root@gc-hk.asia-east2-c.c.annular-bucksaw-448504-h3.internal \ + --metadata ssh-keys=root:ssh-rsa\ AAAAB3NzaC1yc2EAAAADAQABAAABgQDVw/Lamb8wHXeLgCKGbumrocMvq+a6goVFBAuhYk/TVUoislrO1SrrH5YMFc7aQMZNP/mbubirIck8h0wT8hiU070OHO7HuaAyIGgFh4icIX/m7znhvWteG/evxJUN95ZWm4bk+UmGUbbAO4BkSEGub/ENJ3RGR9eJuDabgMha5fyzl9J9sm6jDeXVyGtLOy9NkYYHo/J0kUAwK1YOQ88rAXIhsJ04qsH7256VAdo6enO39Y0RG4NhK3hlRYP46f8NWyCaJFbcz4tpbHNdG9Xbqg7j/RSn7tO5bpB283m/wsZR7kM28x9dzyojJJYycEn9CTUzBjxcBBuKNa57Y+eoBo7q2KXx13ziMvO5k7Bl8GXknl0uguf49hjbPS95CThns+sqz7G3Px8a79BJ1rHEewlmMMJUa/kRY+NAcum0nVkWzZIpR6I2KWMP+8OaJLj97vIHgGydRP8y4I6IiiZBlOlshNJ3iI/XxsSWjWjdWxSHUZtHj4L1IaxclrX+QtU=\ root@gc-hk.asia-east2-c.c.annular-bucksaw-448504-h3.internal \ + --metadata-from-file startup-script=startup-script.sh \ --maintenance-policy=MIGRATE \ --provisioning-model=STANDARD \ --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/trace.append \ @@ -773,6 +815,7 @@ while true; do --shielded-integrity-monitoring \ --labels=goog-ec-src=vm_add-gcloud \ --reservation-affinity=any + if [ $? -eq 0 ]; then echo "第 $i 台虚拟机 $instance_name 创建成功!" else