...
Code Block |
---|
yum install python3 tee /etc/pip.conf << EOF [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com EOF pip3 install tencentcloud-sdk-python-dnspod export SecretId=AKIDgJkH****** export SecretKey=CgTZxO6****** python3 changedns.py zhengyu1992.cn abc 1.1.1.1 |
返回如下结果表示成功
----------------------------------------------
Code Block |
---|
#!/bin/bash
webhookurl=https://oapi.dingtalk.com/robot/send?access_token=0ccbf717fb61bef56d0cc29d25b5d7e79da719997c5d0dca55f709bd54e5ef32
time=$(date)
#currentdnsip=$(dig +short fnsdisk.zhengyu1992.cn A)
currentdnsip=$(python3 listfndsdisk.py)
currentserverip=$(timeout 5 curl -s ifconfig.me)
message="{
\"msgtype\": \"markdown\",
\"markdown\": {
\"title\": \"DNS记录修改\",
\"text\": \"#### DNS记录修改\n\n- 时间: **$time**\n- 域名: **fnsdisk.zhengyu1992.cn**\n- IP:**$currentserverip**\n\"
}
}"
if [ "$currentdnsip" = "$currentserverip" ]; then
echo "The current DNS IP and server IP are the same: $currentdnsip"
exit 0
else
echo "The current DNS IP ($currentdnsip) does not match the server IP ($currentserverip). Updating DNS..."
python3 changefndsdisk.py "$currentserverip"
curl -s "${webhookurl}" -H 'Content-Type: application/json' -d "${message}"
fi |