环境

  • MACOS

安装

brew install scw

创建虚拟机

# 登录
scw init

# 创建服务器
scw instance server create type=STARDUST1-S zone=fr-par-1 image=debian_bullseye root-volume=l:10G name=Denian ip=none ipv6=true project-id=你的账号UUID

# 查看服务器
scw instance server list

# 开机
scw instance server start 你的机器UUID

开机脚本

#!/bin/zsh
MACHINE_UUID="你的机器UUID"

STAR_MACHINE() {
scw instance server start "${MACHINE_UUID}"
}
SEND_NOTIFY(){
echo "成功"
}
while true; do
STATUS=$(scw instance server list | sed -n '2p' | awk '{print $4}')
if [[ ${STATUS} == "starting" ]]; then
echo "Your server status is ${STATUS}"
echo "Starting...Wait for 60 seconds to check again..."
sleep 60
elif [[ ${STATUS} == "archived" ]]; then
echo "Your server status is ${STATUS}"
echo "Now we start your machine..."
STAR_MACHINE
sleep 60
else
SEND_NOTIFY
break
fi
done

参考