
最近比较火的服务器就是昨天双十一的了,这里我就不在过多介绍了,有兴趣的自己去百度一下就可以了,很多人都在推。
今天转载的这篇文章是然你的服务器自动从DC3转到DC8去,使用的是脚本,下面是相关代码:
下载
wget --no-check-certificate -qO BWH.sh 'https://moeclub.org/attachment/LinuxShell/BWH.sh' && chmod a+x BWH.sh
设置
veid='1234560'; # VEID api_key='private_xxxxxxxxxxxxxxxxx'; # API KEY ToLocation='USCA_8'; # 目标机房代码. Timeout='150'; # API频率有限制,单位秒.每150秒运行一次.(不建议过低,否则面板报错.)
运行
#前台运行 bash BWH.sh #后台运行 nohup bash BWH.sh >/dev/null 2>&1 &
预览
#!/bin/bash veid='1234560'; api_key='private_xxxxxxxxxxxxxxxxx'; ToLocation='USCA_8'; Timeout='150'; # START [[ -n "$veid" ]] || exit 1 [[ -n "$api_key" ]] || exit 1 [[ -n "$ToLocation" ]] || exit 1 [[ -n "$Timeout" ]] || exit 1 CurrentLocation=''; Token="?veid=${veid}&api_key=${api_key}"; API_URL="https://api.64clouds.com/v1/"; while [[ "$CurrentLocation" != "$ToLocation" ]]; do CurrentLocation=$(wget --no-check-certificate -qO- "${API_URL}migrate/getLocations${Token}" |grep -o '"currentLocation":"[^"]*"' |cut -d'"' -f4) echo "$(date +"[%Y/%m/%d %H:%M:%S]") ${CurrentLocation}"; if [ -n "$CurrentLocation" -a "$CurrentLocation" != "$ToLocation" ]; then echo -n "${ToLocation}: " wget --no-check-certificate -qO- "${API_URL}migrate/start${Token}&location=${ToLocation}" |grep -o '"message":"[^"]*"' |cut -d'"' -f4 else break; fi sleep ${Timeout}; done
代码转载于: https://moeclub.org/2018/11/12/680/?v=646