Script to update DomainGoogle

Being on a home network with a dynamic IP I have to constantly monitor my IP for if and when it changes. There is a Ddns program to install but I choose to write my one shell script to update to Google every hour by using a crontab I’m not a programming guru but I can learn my example. I looked at many YouTube videos and got the idea. But there is one thing I leaned is there are many videos outdated or just plain wrong. I patched together a script that worked without causing an error. The first time after I installed “sendMail” for WordPress notifications I got spammed with error emails from crontab. The URL to Google Domains was not up to the latest standards with the user and password inline with the address. I learned to shut off the email alerts but I just had to fix the problem.

The problem was wget and using usename:password@domains.google. That apparently not a legitimate url. By using the wget switch --user=(usename) --password=(password) stopped the error message. I added a additional part of my code to make sure the internet was present. as not to have the script cause a freeze.

wget --user=(username) --password=(password)  -O dns_update_results.txt https://domains.google.com/nic/update?hostname=DomainNane.com

#!/bin/bash -e 
if [[ "$(ping -c 1 8.8.8.8 | grep '100% packet loss' )" != "" ]]; then
echo "Internet isn't present $(date)" >> internet_not_present.info
exit 1
else
echo "Internet is present $(date)" >> internet_Is_present.info
wget --user=(usename) --password=(password) -O dns_update_results.txt https://domains.google.com/nic/update?hostname=DomainNane.com
echo " Last run $(date)" >> dns_update_results.txt
cat dns_update_results.txt >> dns_update_results.info
rm -f dns_update_results_Line_numbers.info
cat -n dns_update_results.info >> dns_update_results_Line_numbers.info

fi

I hope this is useful to someone. There seems to be an exploit with the dns updater app so it makes sense to use this script. Thanks for your time. I’m sorry this blog isn’t in Mandarin with all the hits from China 😁

Welcome to horndogs blog site

I have so much to say so were do I start? This site is dedicated to Hoshi Sato.

I’m a technical oriented person and a gifted trouble shooter. This sit is coming to you from my home network on a raspberry pi running Debian 9 stretch Linux. Web server is Apache2, PHP, and mysql using WordPress. I haven’t done this for some years put it’s slowly coming back to me. This site is all on a server with the foot print of a credit card . The electricity to run this is about the same as my cell phone charger. I am inspired to do this project to get word to my beloved Hoshi Sato (not her real name)