Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

狗爹改了API,需要传入数组才行 #5

Merged
merged 1 commit into from
May 11, 2018
Merged

狗爹改了API,需要传入数组才行 #5

merged 1 commit into from
May 11, 2018

Conversation

firedent
Copy link
Contributor

No description provided.

@mritd
Copy link
Owner

mritd commented May 11, 2018

哈哈 我也昨天刚去看了一下,我说我家里的 ddns 脚本怎么失效了,昨天看了下 api确实改了

@mritd mritd merged commit b1b4505 into mritd:master May 11, 2018
@mritd mritd mentioned this pull request May 11, 2018
@mritd
Copy link
Owner

mritd commented May 11, 2018

其实我感觉扔上去个小脚本更舒服,然后系统开个 定时任务,我现在在 tomato 上自己编译了一个 curl 然后调用的脚本

#!/bin/sh

export PATH=/jffs/bin:$PATH

echo "Exec Date: `date "+%Y-%m-%d %H:%M:%S"`"

GD_NAME="home"
GD_DOMAIN="xxx.io"
GD_TTL="600"
GD_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
GD_SECRET="xxxxxxxxxxxxxxxxxx"
GD_API_ADDRESS="https://api.godaddy.com/v1/domains/${GD_DOMAIN}/records/A/${GD_NAME}"
GD_DOMAIN_IP=`nslookup ${GD_NAME}.${GD_DOMAIN} 114.114.114.114 2>&1 | grep 'Address 1' | tail -n1 | awk '{print $3}'`
CURRENT_IP=`nvram get wan_ipaddr`

echo "CURRENT_IP: ${CURRENT_IP}"
echo "GD_DOMAIN_IP: ${GD_DOMAIN_IP}"

update_record() {
        dcurl -X PUT "https://api.godaddy.com/v1/domains/${GD_DOMAIN}/records/A/${GD_NAME}" \
        --cacert /jffs/cacert.pem \
            -H "accept: application/json" \
            -H "Content-Type: application/json" \
            -H "Authorization: sso-key ${GD_KEY}:${GD_SECRET}" \
            -d "[ { \"data\": \"${CURRENT_IP}\", \"ttl\": ${GD_TTL} }]"
}

if [ "${CURRENT_IP}" = "${GD_DOMAIN_IP}" ]; then
    echo "Skipping..."
    exit 0
else
    echo "Changing..."
    update_record
    if [ "$?" -eq "0" ]; then
        echo "DNS Update Success..."
    else
        echo "DNS Update Failed..."
    fi
fi

@firedent
Copy link
Contributor Author

毕竟用户界面可以降低使用门槛。
我没刷梅林之前是用python写脚本然后定时更新。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants