Skip to content

Instantly share code, notes, and snippets.

@dhsathiya
Last active July 30, 2021 07:54
Show Gist options
  • Save dhsathiya/e43f68f71249d42af42c83164d835e7b to your computer and use it in GitHub Desktop.
Save dhsathiya/e43f68f71249d42af42c83164d835e7b to your computer and use it in GitHub Desktop.
#!/bin/bash
IP=$(curl -4 icanhazip.com)
#echo $IP > /root/ip-changer/currentIPdd
OLD_IP=$(cat /root/ip-changer/currentIP)
echo "================ $(date) ================" >> /root/ip-changer/checkLog
if [ "$IP" != "$OLD_IP" ]; then
echo $IP > /root/ip-changer/currentIP
/usr/local/bin/cfcli edit curling.techio.dev $IP
echo "changed OLD_IP=$OLD_IP NEW_IP=$IP" >> /root/ip-changer/checkLog
fi
# Uses: https://www.npmjs.com/package/cloudflare-cli
# Cron
# * * * * * bash /root/ip-changer/main.sh
@dhsathiya
Copy link
Author

New script

mkdir /root/ip-changer

#!/bin/bash

IP=$(curl -4 icanhazip.com)
#echo $IP > /root/ip-changer/currentIPdd
OLD_IP=$(cat /root/ip-changer/currentIP)

echo "================ $(date)  ================" >> /root/ip-changer/checkLog

if [ "$IP" != "$OLD_IP" ]; then
	echo $IP > /root/ip-changer/currentIP
	/usr/bin/cfcli edit notify.example.com $IP
	echo "changed OLD_IP=$OLD_IP NEW_IP=$IP" >> /root/ip-changer/checkLog
fi
#~/.cfcli.yml 
defaults:
    token: yuhwdqwrqeoiy21
    #email: [email protected] #Only required if using legacy API Key
    domain: example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment