Created
June 17, 2013 00:44
-
-
Save wenjianhn/5794032 to your computer and use it in GitHub Desktop.
#cloudflare modify dns record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
if [[ $1 == "" ]] | |
then | |
file=`basename $0` | |
echo "Usage:" | |
echo " $file IP" | |
# TODO(wenjianhn): subname name and more as args | |
# echo: example | |
exit 1 | |
fi | |
new_ip=$1 | |
subname=proxy | |
name=$subname.wenjian.me | |
tkn=123 | |
py_printid="print [obj['rec_id'] \ | |
for obj in r['response']['recs']['objs'] \ | |
if obj['name'] == '$name'][0]" | |
rec_id=`curl --silent https://www.cloudflare.com/api_json.html \ | |
-d 'a=rec_load_all' \ | |
-d "tkn=$tkn" \ | |
-d '[email protected]' \ | |
-d 'z=wenjian.me' \ | |
-d 'interval=20' \ | |
| python -c "import sys, json; r = json.load(sys.stdin); $py_printid"` | |
curl --silent https://www.cloudflare.com/api_json.html \ | |
-d 'a=rec_edit' \ | |
-d "tkn=$tkn" \ | |
-d "id=$rec_id" \ | |
-d '[email protected]' \ | |
-d 'z=wenjian.me' \ | |
-d 'type=A' \ | |
-d "name=$subname" \ | |
-d "content=$new_ip" \ | |
-d 'service_mode=0' \ | |
-d 'ttl=120' | python -m json.tool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment