Sets a cloudflare subdomain to your IP every 15 minutes.
$ brew install jq
$ crontab -e
# add this ->
30 * * * * /Users/canada/Documents/update-ip.sh
#!/bin/bash | |
LOGIN="<cloudlfare email>" | |
TOKEN="<cloudflare token>" | |
DOMAIN="example.com" | |
SUBDOMAIN="admin.example.com" | |
RECORD_ID="<record id>" # Replace with the Record ID | |
IP=`curl http://jsonip.com | /usr/local/bin/jq -r '.ip'` | |
curl https://www.cloudflare.com/api_json.html \ | |
-d 'a=rec_edit' \ | |
-d "tkn=$TOKEN" \ | |
-d "id=$RECORD_ID" \ | |
-d "email=$LOGIN" \ | |
-d "z=$DOMAIN" \ | |
-d 'type=A' \ | |
-d "name=$SUBDOMAIN" \ | |
-d "content=$IP" \ | |
-d 'service_mode=0' \ | |
-d 'ttl=1' |