diff --git a/README.md b/README.md index ea8ac154..919b094a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ To setup Chronometer2 with an PiTFT+ screen: - Install Pi-hole by running `curl -sSL https://install.pi-hole.net | bash`. ### Setup Chronometer2 -- Get a copy of Chronometer2 by running `wget https://raw.githubusercontent.com/jpmck/chronometer2/master/chronometer2.sh` from pi's home directory +- Get a copy of Chronometer2 by running `wget -N https://raw.githubusercontent.com/jpmck/chronometer2/master/chronometer2.sh` from pi's home directory - Make Chronometer2 executable by running `sudo chmod +x chronometer2.sh`. - Set Chronometer2 to auto run by adding `./chronometer2.sh` to the last line of `~/.bashrc`. - Reboot your Pi-Hole by running `sudo reboot`. Chronometer2 should now run when your Pi-Hole has completed booting. @@ -31,3 +31,6 @@ To do so, edit cron as root (`sudo crontab -e`) and add the following: 00 00 * * * sh -c 'echo "0" > /sys/class/backlight/soc\:backlight/brightness' # Turn on the PiTFT+ at 8:00 am 00 08 * * * sh -c 'echo "1" > /sys/class/backlight/soc\:backlight/brightness' + +## Updating Chronometer2 +- Just run `wget -N https://raw.githubusercontent.com/jpmck/chronometer2/master/chronometer2.sh` again from pi's home directory. diff --git a/chronometer2.sh b/chronometer2.sh index 8dd4bb41..6e44cba8 100644 --- a/chronometer2.sh +++ b/chronometer2.sh @@ -45,7 +45,8 @@ GetFTLData() { } GetSummaryInformation() { - local summary=$(GetFTLData "stats") + local summary + summary=$(GetFTLData "stats") domains_being_blocked_raw=$(grep "domains_being_blocked" <<< "${summary}" | grep -Eo "[0-9]+$") domains_being_blocked=$(printf "%'.f" ${domains_being_blocked_raw}) dns_queries_today_raw=$(grep "dns_queries_today" <<< "$summary" | grep -Eo "[0-9]+$") @@ -187,17 +188,15 @@ GetVersionInformation() { source piHoleVersion # was the last check today? - if [ "${today}" != "${lastCheck}" ]; then - # no, it wasn't today - + if [ "${today}" != "${lastCheck}" ]; then # no, it wasn't today # Today is... today=$(date +%Y%m%d) # what are the latest available versions? # TODO: update if necessary if added to pihole - piholeVersionLatest=$(pihole -v -p -l | tr -d "[:alpha:]") - webVersionLatest=$(pihole -v -a -l | tr -d "[:alpha:]") - ftlVersionLatest=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n[:alpha:]') + piholeVersionLatest=$(pihole -v -p -l | awk '{print $5}' | tr -d "[:alpha:]") + webVersionLatest=$(pihole -v -a -l | awk '{print $5}' | tr -d "[:alpha:]") + ftlVersionLatest=$(pihole -v -f -l | awk '{print $5}' | tr -d "[:alpha:]") chronometer2VersionLatest=$(curl -sI https://github.com/jpmck/chronometer2/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n[:alpha:]') # check if everything is up-to-date... @@ -250,8 +249,6 @@ GetVersionInformation() { fi fi - - # write it all to the file echo "lastCheck="${today} > ./piHoleVersion @@ -275,9 +272,9 @@ GetVersionInformation() { # else the file dosn't exist else # We're using... - piholeVersion=$(pihole -v -p -c | tr -d "[:alpha:]") - webVersion=$(pihole -v -a -c | tr -d "[:alpha:]") - ftlVersion=$(/usr/bin/pihole-FTL version | tr -d "[:alpha:]") + piholeVersion=$(pihole -v -p | awk '{print $4}' | tr -d "[:alpha:]") + webVersion=$(pihole -v -a | awk '{print $4}' | tr -d "[:alpha:]") + ftlVersion=$(pihole -v -f | awk '{print $4}' | tr -d "[:alpha:]") echo "lastCheck=0" > ./piHoleVersion echo "piholeVersion="$piholeVersion >> ./piHoleVersion @@ -297,7 +294,7 @@ outputDHCPInformation() { } outputJSON() { - GetSummaryInformatioon + GetSummaryInformation echo "{\"domains_being_blocked\":${domains_being_blocked_raw},\"dns_queries_today\":${dns_queries_today_raw},\"ads_blocked_today\":${ads_blocked_today_raw},\"ads_percentage_today\":${ads_percentage_today_raw}}" } @@ -424,7 +421,7 @@ if [[ $# = 0 ]]; then GetVersionInformation echo " - $versionStatus" echo "" - printf "Chronometer2 will start in " + printf "Chronometer2 will start in" for i in 5 4 3 2 1 do