#循环开机脚本#!/usr/bin/env bashMACHINE_UUID=""BOT_API=""CHAT_ID=""STAR_MACHINE(){ scw instance server start "${MACHINE_UUID}"}SEND_NOTIFY(){ curl -X POST \
-H 'Content-Type: application/json'\
-d '{"chat_id": '${CHAT_ID}', "text": "Your Sacleway machine is opening now."}'\
https://api.telegram.org/bot${BOT_API}/sendMessage
}while true;doSTATUS=$(scw instance server list | sed -n '2p'| awk '{print $4}')if[[${STATUS}=="starting"]];thenecho"Your server status is ${STATUS}"echo"Starting...Wait for 60 seconds to check again..." sleep 60elif[[${STATUS}=="archived"]];thenecho"Your server status is ${STATUS}"echo"Now we start your machine..." STAR_MACHINE
sleep 60else SEND_NOTIFY
breakfidone