Friday, July 31, 2020
starting my own ddns.
have my own vm with westhost… barilin.com
using cron.
# Updated 2/9/19 2,7,12,17,22,27,32,37,42,47,52,57 * * * * /root/bin/reportipaddress &> /dev/null
I have it running the foloowing every 5 minutes…
pushing the IP Address up to my VM
root@cp1:~/bin# cat reportipaddress DATE=/usr/bin/date QUERY="" QUERY="/usr/bin/curl http://barilin.com/whatipaddressami" $QUERY if [ "$QUERY" != "" ]; then $ECHO $DATE >> /var/log/reportipaddress.log fi; root@cp1:~/bin#
I have it report into my vm and have it query a non exsistant url..
Then I parse the logs every 5 mintues with cron
5,10,15,20,25,30,35,40,45,50,55,59 * * * * ~/bin/5minutes.sh
cron calls a script
[uscopley@sl-508-21 bin]$ cat 5minutes.sh CAT=/usr/bin/cat FILE="/home/uscopley/access-logs/barilin.com" HEADHTML="/home/uscopley/bin/5minutes.head" TAILHTML="/home/uscopley/bin/5minutes.tail" GREP=/usr/bin/grep TAIL="/usr/bin/tail -10" STRING=whatipaddressami REPORT="/home/uscopley/www/reportipaddress.html" # # # $CAT $HEADHTML > $REPORT $CAT $FILE | $GREP $STRING | $TAIL >> $REPORT $CAT $TAILHTML >> $REPORT # # # #cat ~/access-logs/barilin.com | grep whatipaddressami | tail -3 > ~/www/reportipaddress.html
The next part hasn’t been written yet. I’m going to grab that ip address that’s reported
and shove it into dns… With my home A name.
Thursday, July 30, 2020
whole lotta pies / Download config on reboot
So, I like to have all my pies download a set of configs at boot. Allows me to make a change
a centeralized location and push it out to everyone (When they reboot)
All pies get this in their /etc/rc.d/rc.local
/home/zero/updates/update.sh # /etc/sethostalias.sh > /etc/hostalias # /usr/sbin/netdate ntp1 >> /home/netdate/n3.netdate.log # sleep 20; /etc/rc.d/rc.ntpd restart #
and then of course /etc/fstab has a samba mounted share with the following
//cp1/zero /home/zero cifs user=timc,pass=[password] 0 0
and the /home/zero/updates/update.sh has the following
# # Setup some variables # CP="/usr/bin/cp" DIR="/home/zero/updates" MKDIR="/usr/bin/mkdir" # # Updatre aliases and hosts and profiles from CP1 # $CP $DIR/sethostalias.sh /etc $CP $DIR/hosts /etc $CP $DIR/profile /etc $CP $DIR/alias /etc # # Make a bin directory for root on host # EDIR="/root/bin" if [ ! -d $EDIR ]; then $MKDIR $EDIR $CP $DIR/bin/ $EDIR fi # # Couple files for Serial stuff on PI's # $CP $DIR/config.txt /root $CP $DIR/cmdline.txt /root $CP $DIR/inittab /root # # Couple fixes for snmp / ntp $CP $DIR/rc.M /etc/rc.d/ $CP $DIR/snmpd.conf /etc/snmp/ $CP $DIR/ntp.conf /etc/
with all the appropiate file goodies. This seems to fluctuate based upon what I’m doing…