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.
Movies… mkv to mp4 using ffmpeg command line
for some reason, everyonce in awhile I’m dealing with a device that cannot deal with mkv
extensions, so I convert em….
doneroot@cp1:~/bin# cat mkv2mp4 FFMPEG=/usr/bin/ffmpeg FROM=mkv TO=mp4 for FILE in *.$FROM do $FFMPEG -i "$FILE" -codec copy "${FILE%.*}.$TO" done root@cp1:~/bin#
runs though it pretty quick.
Restart gpsd on a daily basis using expect!
cron…
26 3 * * * /root/bin/startgpsd.sh >> /var/log/startgpsd.log # Run Monthly at the 9th day for Leap second file # #20 2 9 * * /usr/bin/update-leap >> /var/log/update.leap.second.log
which runs a shell script which calls an expect script.
#!/bin/sh -e ####################################################################### # LED Pin - wiringPi pin 0 is BCM_GPIO 17. (Physical pin 11) # DATE=`/bin/date` echo "========================================================================" echo $DATE /root/bin/startgpsd.exp
root@ntpd1:~/bin# cat startgpsd.exp #!/usr/bin/expect -f spawn $env(SHELL) match_max 100000 send -- "cd /etc/rc.d/r" expect -exact "#" send -- "./rc.gpsd stopr" expect -exact "#" send -- "./rc.gpsd stopr" expect -exact "#" send -- "./rc.gpsd startr" expect -exact "#" send -- "exitr" expect eof root@ntpd1:~/bin#
NTP Daemon Status
love love love expect!!!
expect script to checkout ntp status
#!/usr/bin/expect -f # set timeout -1 spawn /bin/sh #match_max 100000 expect "# " send -- "ntpqr" expect "> " send -- "sysinfor" expect "> " send -- "sysstatsr" expect "> " send -- "quitr" expect "# " send -- "exitr" close
which outputs the following
root@cp1:~/bin# ntpdstatus spawn /bin/sh root@cp1:~/bin# ntpq ntpq> sysinfo associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync, system peer: ntp1:123 system peer mode: client leap indicator: 00 stratum: 3 log2 precision: -24 root delay: 48.358 root dispersion: 85.481 reference ID: 192.168.1.8 reference time: e2cdbe58.de9aa010 Thu, Jul 30 2020 14:47:04.869 system jitter: 0.000000 clock jitter: 21.932 clock wander: 1.152 broadcast delay: -50.000 symm. auth. delay: 0.000 ntpq> sysstats uptime: 382817 sysstats reset: 382817 packets received: 1193 current version: 1169 older version: 20 bad length or format: 0 authentication failed: 0 declined: 0 restricted: 0 rate limited: 0 KoD responses: 0 processed for time: 592 ntpq> quit root@cp1:~/bin# root@cp1:~/bin#
Thursday, July 30, 2020
all my pies backup critical files
cron has the following entry
20 3 * * * /usr/sbin/netdate cp1 >> /home/netdate/n3.netdate.log 10 3 3 * * /root/bin/backupnode.sh >> /var/log/backupnode.log
which runs the following.
root@nas3:~/bin# cat backupnode.sh #!/bin/bash START=`/bin/date +%s` CP="/bin/cp -Ru" DATE=$(/usr/bin/date +%m%d%y-%H%M%S) ECHO=/usr/bin/echo AWK=/usr/bin/awk CAT=/usr/bin/cat HOSTNAME=/etc/HOSTNAME HOST=`$CAT $HOSTNAME | $AWK 'BEGIN { FS = "."} ; { print $1 }'` LOG="/home/zero/systems/$HOST.log" LLOG="/var/log/system-backup.log" ZERODIR="/home/zero/systems/$HOST/" BACKUPDIRS="/root /etc /srv/httpd/htdocs /usr/spool/cron/crontabs" # # System Files # for DIR in $BACKUPDIRS do $CP $DIR $ZERODIR done END=`/bin/date +%s` RUNTIME=$((END-START)) $ECHO "$DATE - Runtime = $RUNTIME" >> $LOG $ECHO "$DATE - Runtime = $RUNTIME" >> $LLOG