Skip to content

Commit 29f7273

Browse files
committed
Fixed Version Check
Minor - Updated 'pihole -v' calls in GetVersionInformation - Fixed mispelled GetSummaryInformation function call in outputJSON
1 parent 6e07920 commit 29f7273

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To setup Chronometer2 with an PiTFT+ screen:
1616
- Install Pi-hole by running `curl -sSL https://install.pi-hole.net | bash`.
1717

1818
### Setup Chronometer2
19-
- Get a copy of Chronometer2 by running `wget https://raw.githubusercontent.com/jpmck/chronometer2/master/chronometer2.sh` from pi's home directory
19+
- Get a copy of Chronometer2 by running `wget -N https://raw.githubusercontent.com/jpmck/chronometer2/master/chronometer2.sh` from pi's home directory
2020
- Make Chronometer2 executable by running `sudo chmod +x chronometer2.sh`.
2121
- Set Chronometer2 to auto run by adding `./chronometer2.sh` to the last line of `~/.bashrc`.
2222
- 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:
3131
00 00 * * * sh -c 'echo "0" > /sys/class/backlight/soc\:backlight/brightness'
3232
# Turn on the PiTFT+ at 8:00 am
3333
00 08 * * * sh -c 'echo "1" > /sys/class/backlight/soc\:backlight/brightness'</pre>
34+
35+
## Updating Chronometer2
36+
- Just run `wget -N https://raw.githubusercontent.com/jpmck/chronometer2/master/chronometer2.sh` again from pi's home directory.

chronometer2.sh

+11-14
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ GetFTLData() {
4545
}
4646

4747
GetSummaryInformation() {
48-
local summary=$(GetFTLData "stats")
48+
local summary
49+
summary=$(GetFTLData "stats")
4950
domains_being_blocked_raw=$(grep "domains_being_blocked" <<< "${summary}" | grep -Eo "[0-9]+$")
5051
domains_being_blocked=$(printf "%'.f" ${domains_being_blocked_raw})
5152
dns_queries_today_raw=$(grep "dns_queries_today" <<< "$summary" | grep -Eo "[0-9]+$")
@@ -187,17 +188,15 @@ GetVersionInformation() {
187188
source piHoleVersion
188189

189190
# was the last check today?
190-
if [ "${today}" != "${lastCheck}" ]; then
191-
# no, it wasn't today
192-
191+
if [ "${today}" != "${lastCheck}" ]; then # no, it wasn't today
193192
# Today is...
194193
today=$(date +%Y%m%d)
195194

196195
# what are the latest available versions?
197196
# TODO: update if necessary if added to pihole
198-
piholeVersionLatest=$(pihole -v -p -l | tr -d "[:alpha:]")
199-
webVersionLatest=$(pihole -v -a -l | tr -d "[:alpha:]")
200-
ftlVersionLatest=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n[:alpha:]')
197+
piholeVersionLatest=$(pihole -v -p -l | awk '{print $5}' | tr -d "[:alpha:]")
198+
webVersionLatest=$(pihole -v -a -l | awk '{print $5}' | tr -d "[:alpha:]")
199+
ftlVersionLatest=$(pihole -v -f -l | awk '{print $5}' | tr -d "[:alpha:]")
201200
chronometer2VersionLatest=$(curl -sI https://github.com/jpmck/chronometer2/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n[:alpha:]')
202201

203202
# check if everything is up-to-date...
@@ -250,8 +249,6 @@ GetVersionInformation() {
250249
fi
251250
fi
252251

253-
254-
255252
# write it all to the file
256253
echo "lastCheck="${today} > ./piHoleVersion
257254

@@ -275,9 +272,9 @@ GetVersionInformation() {
275272
# else the file dosn't exist
276273
else
277274
# We're using...
278-
piholeVersion=$(pihole -v -p -c | tr -d "[:alpha:]")
279-
webVersion=$(pihole -v -a -c | tr -d "[:alpha:]")
280-
ftlVersion=$(/usr/bin/pihole-FTL version | tr -d "[:alpha:]")
275+
piholeVersion=$(pihole -v -p | awk '{print $4}' | tr -d "[:alpha:]")
276+
webVersion=$(pihole -v -a | awk '{print $4}' | tr -d "[:alpha:]")
277+
ftlVersion=$(pihole -v -f | awk '{print $4}' | tr -d "[:alpha:]")
281278

282279
echo "lastCheck=0" > ./piHoleVersion
283280
echo "piholeVersion="$piholeVersion >> ./piHoleVersion
@@ -297,7 +294,7 @@ outputDHCPInformation() {
297294
}
298295

299296
outputJSON() {
300-
GetSummaryInformatioon
297+
GetSummaryInformation
301298
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}}"
302299
}
303300

@@ -424,7 +421,7 @@ if [[ $# = 0 ]]; then
424421
GetVersionInformation
425422
echo " - $versionStatus"
426423
echo ""
427-
printf "Chronometer2 will start in "
424+
printf "Chronometer2 will start in"
428425

429426
for i in 5 4 3 2 1
430427
do

0 commit comments

Comments
 (0)