以下是我之前刷 AMD 时用的脚本,代码全是本人手写(AI 写出来完全不符合要求我真服了)

使用方式

  1. 确保你正在看论坛的电脑使用的是 Linux 系统,或者你在 VPS 上运行此代码
  2. 安装 GCP 的 Cloud SDK,见 https://docs.cloud.google.com/sdk/docs/install?hl=zh-cn
  3. 运行 gcloud auth login 登录你的 Google Cloud 账号
  4. 将脚本代码写到本地的 a.sh 文件下
  5. chmod +x ./a.sh
  6. 运行脚本,./a.sh 虚拟机名称 虚拟机区(比如us-west1-a) 项目ID

脚本代码

#!/usr/bin/env bashprint_info() {  echo "[信息] $1"}print_success() {  echo "[成功] $1"}print_warning() {  echo "[警告] $1"}print_info "正在设置gcloud项目为: $3"gcloud config set project "$3" >/dev/nullattempt_counter=1while true; do  print_info "=================================================="  print_info "第 $attempt_counter 次尝试..."  print_info "正在启动虚拟机 $1"  gcloud compute instances start "$1" --zone="$2" --quiet  print_info "正在检查CPU平台..."  CPU_PLATFORM="$(gcloud compute instances describe "$1" --zone="$2" --format="value(cpuPlatform)")"  if [[ "$CPU_PLATFORM" == "AMD Rome" || "$CPU_PLATFORM" == "AMD Milan" ]]; then    print_success "恭喜!已成功刷到AMD CPU: $CPU_PLATFORM"    print_info "脚本执行完毕。"    exit 0  else    print_warning "当前CPU为: $CPU_PLATFORM (不是AMD)。准备进行下一次尝试"  fi  print_info "正在关停虚拟机 $1"  gcloud compute instances stop "$1" --zone="$2" --quiet  ((attempt_counter++))done

能帮顶下帖子吗,鸡腿自己留着升级就行只希望你评论下