Skip to content

Commit

Permalink
Added log file in variable logfile Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
navilg committed Jul 19, 2020
1 parent ef6417a commit ce72874
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
**What is this repository for?**

* Public IP address of many hosting servers are dynamic and it changes based on availability. Some examples include AWS EC2 instance, Home Servers, GCP Cloud, etc.
* This require updating the IP address in goDaddy DNS record so that requests are forwarded to correct IP address.
* This script uses cron jobs to check the current Public IP address of server and update the IP address in goDaddy Manage DNS.
* This require updating the IP address in GoDaddy DNS record so that requests are forwarded to correct IP address.
* This script uses cron jobs to check the current Public IP address of server and update the IP address in GoDaddy Manage DNS.
* OS: Linux. Tested on Ubuntu server 18.04 LTS with BASH shell.
* Prerequisite tools: curl, BASH shell.
* Required utility tools: curl, BASH shell.

**How do I get set up ?**

* Clone this repository in your server.
* Open godaddyDDNS/godaddyDDNS.properties file
* Open godaddyDDNS/godaddy-ddns.properties file
* Update the properties values as below:

*Comment (#) is not supported in property file as of now. Avoid using # to ignore the lines.*

domain=domain.com

name=subdomainORwww
Expand All @@ -29,7 +27,7 @@ secret=secret-key-value-from-godaddy-developer-console


e.g. To update DNS Name *navi.example.com*

```
domain=example.com
name=navi
Expand All @@ -39,29 +37,32 @@ key=cvvgfvfd54jghgz8s
ttl=3600
secret=dfgsx6daflx5]gkhhi8yjxf

* Key and Secret can be generated from godaddy Developer page. https://developer.godaddy.com/getstarted
```
* Key and Secret can be generated from GoDaddy Developer page. https://developer.godaddy.com/getstarted
* After updating. Run the script.
*./godaddy-ddns.sh*
* Check the log in godaddyDDNS.log file
* If log status is OK. Its working fine. Verify the DNS record in godaddy account.
* **Updating the DNS record in godaddy doesn't mean DNS server is also updated. DNS server updation completely depends on TTL value. Its good to have short TTL value for highly dynamic IP address.**
* If log status is OK. Its working fine. Verify the DNS record in GoDaddy account.
* **Updating the DNS record in GoDaddy doesn't mean DNS server is also updated. DNS server updation completely depends on TTL value. Its good to have short TTL value for highly dynamic IP address.**
* Create a crontab entry to run the godaddyDDNS.sh file every five minutes.

*crontab -e*

```
crontab -e
```
Add below lines

*\*/5 * * * * /Path/to/godaddy-ddns/godaddy-ddns.sh >/dev/null 2>&1*
```
*/5 * * * * /Path/to/godaddy-ddns/godaddy-ddns.sh >/dev/null 2>&1
*@reboot /Path/to/godaddy-ddns/godaddy-ddns.sh >/dev/null 2>&1*
@reboot /Path/to/godaddy-ddns/godaddy-ddns.sh >/dev/null 2>&1
```

Save it

* 'How to' Youtube video --> https://youtu.be/lnPPdYexf4E

**NOTES:**
goDaddy supports 60 requests per minutes. This scripts uses 2 requests. So, Make sure to create cronjob accordingly so that request doesn't exceed 60 request per minute or else it will fail.
GoDaddy supports 60 requests per minutes. This scripts uses 2 requests. So, Make sure to create cronjob accordingly so that request doesn't exceed 60 request per minute or else it will fail.


**Contribution guidelines**
Expand All @@ -71,7 +72,7 @@ goDaddy supports 60 requests per minutes. This scripts uses 2 requests. So, Make

**How to reach me ?**

* Repo owner or admin: Navratan Gupta <[email protected]>
* Repo owner or admin: [Navratan Gupta](mailto:[email protected])
* You can reach out to me on [email protected] for any feedback.

**Special mention to https://github.com/markafox/GoDaddy_Powershell_DDNS which is base for this script.**
23 changes: 12 additions & 11 deletions godaddy-ddns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function initialize()
DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)
# Properties file to store value of domain, subdomain, keys and others
properties_file="$DIR/godaddy-ddns.properties"
logfile="$DIR/godaddy-ddns.log"

# Source the values from properties file
source $properties_file
Expand Down Expand Up @@ -93,22 +94,22 @@ function setDNSRecord()
function writeLog()
{
if [[ $1 -eq 0 ]]; then
echo "DNS Name: "$name.$domain"" > $DIR/godaddy-ddns.log
echo "DNS IP: $currentIp" >> $DIR/godaddy-ddns.log
echo "DNS Name: "$name.$domain"" > "$logfile"
echo "DNS IP: $currentIp" >> "$logfile"
echo "TTL: $ttl"
echo "Status: OK" >> $DIR/godaddy-ddns.log
echo "Status: OK" >> "$logfile"
return 0
elif [[ $1 -eq 100 ]]; then
echo "DNS Name: "$name.$domain"" > $DIR/godaddy-ddns.log
echo "DNS IP: " >> $DIR/godaddy-ddns.log
echo "TTL: " >> $DIR/godaddy-ddns.log
echo "Status: Unknown - "$2"" >> $DIR/godaddy-ddns.log
echo "DNS Name: "$name.$domain"" > "$logfile"
echo "DNS IP: " >> "$logfile"
echo "TTL: " >> "$logfile"
echo "Status: Unknown - "$2"" >> "$logfile"
return 100
else
echo "DNS Name: "$name.$domain"" > $DIR/godaddy-ddns.log
echo "DNS IP: " >> $DIR/godaddy-ddns.log
echo "TTL: " >> $DIR/godaddy-ddns.log
echo "Status: NOT OK - "$2"" >> $DIR/godaddy-ddns.log
echo "DNS Name: "$name.$domain"" > "$logfile"
echo "DNS IP: " >> "$logfile"
echo "TTL: " >> "$logfile"
echo "Status: NOT OK - "$2"" >> "$logfile"
return 1
fi
}
Expand Down

0 comments on commit ce72874

Please sign in to comment.