Created
October 29, 2019 16:01
-
-
Save 0xjams/648642c0f55c3e685ae34d9384b583ae to your computer and use it in GitHub Desktop.
Namecheap DDNS updater for pfsense, this one had to be updated for tcsh. Most public ones are written for bash
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/tcsh | |
# Shell script to update namecheap.com dynamic dns | |
# from a pfsense Firewall, had to be adapted from other bash solutions | |
set DOMAIN='' | |
set PASSWORD='' | |
set HOSTNAME='' | |
set EMAIL='' | |
set CACHED_IP_FILE='./namecheap_ddns_ip.txt' | |
set CACHED_IP_FILE_HISTORY='./namecheap_ddns_ip_history.txt' | |
set LAST_CURL_OUTPUT='./namecheap_response.txt' | |
set DATE=`date +%Y%m%d` | |
set CURRENT_IP=`curl -s ifconfig.co` | |
set UPDATE_IP="false" | |
if ( -e $CACHED_IP_FILE ) then | |
set FILE_IP=`cat $CACHED_IP_FILE` | |
if ($FILE_IP == $CURRENT_IP) then | |
echo "IP has not changed" | |
else | |
set UPDATE_IP="true" | |
endif | |
else | |
echo $CURRENT_IP > $CACHED_IP_FILE | |
set UPDATE_IP="true" | |
endif | |
if ($UPDATE_IP == "true") then | |
#set REQUEST='https://dynamicdns.park-your-domain.com/update?host=$HOSTNAME&domain=$DOMAIN&password=$PASSWORD&ip=$CURRENT_IP' | |
curl -s "https://dynamicdns.park-your-domain.com/update?host=$HOSTNAME&domain=$DOMAIN&password=$PASSWORD&ip=$CURRENT_IP" -o $LAST_CURL_OUTPUT | |
echo "IP WAS UPDATED" | |
#echo $RESPONSE | |
printf "$DATE\t${CURRENT_IP}" >> $CACHED_IP_FILE_HISTORY | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment