Skip to content

Commit

Permalink
Fixed Version Check
Browse files Browse the repository at this point in the history
Minor
- Updated 'pihole -v' calls in GetVersionInformation
- Fixed mispelled GetSummaryInformation function call in outputJSON
  • Loading branch information
jpmck committed Jun 21, 2017
1 parent 6e07920 commit 29f7273
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'</pre>

## Updating Chronometer2
- Just run `wget -N https://raw.githubusercontent.com/jpmck/chronometer2/master/chronometer2.sh` again from pi's home directory.
25 changes: 11 additions & 14 deletions chronometer2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]+$")
Expand Down Expand Up @@ -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...
Expand Down Expand Up @@ -250,8 +249,6 @@ GetVersionInformation() {
fi
fi



# write it all to the file
echo "lastCheck="${today} > ./piHoleVersion

Expand All @@ -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
Expand All @@ -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}}"
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 29f7273

Please sign in to comment.