Version check amalgamation and removal of && || logic.

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
Dan Schaper 2017-03-04 17:54:38 -08:00
parent 05640f9a6b
commit dc44fc9e27
No known key found for this signature in database
GPG key ID: 572E999E385B7BFC

View file

@ -24,6 +24,8 @@ WHITELISTFILE="/etc/pihole/whitelist.txt"
BLACKLISTFILE="/etc/pihole/blacklist.txt" BLACKLISTFILE="/etc/pihole/blacklist.txt"
ADLISTFILE="/etc/pihole/adlists.list" ADLISTFILE="/etc/pihole/adlists.list"
PIHOLELOG="/var/log/pihole.log" PIHOLELOG="/var/log/pihole.log"
PIHOLEGITDIR="/etc/.pihole/"
ADMINGITDIR="/var/www/html/admin/"
WHITELISTMATCHES="/tmp/whitelistmatches.list" WHITELISTMATCHES="/tmp/whitelistmatches.list"
TIMEOUT=60 TIMEOUT=60
@ -111,22 +113,48 @@ version_check() {
header_write "Detecting Installed Package Versions:" header_write "Detecting Installed Package Versions:"
local error_found local error_found
local pi_hole_ver
local pi_hole_branch
local pi_hole_commit
local admin_ver
local admin_branch
local admin_commit
local light_ver
local php_ver
error_found=0 error_found=0
local pi_hole_ver="$(cd /etc/.pihole/ && git describe --tags --abbrev=0)" \ if [[ -d "${PIHOLEGITDIR}" ]]; then
&& log_echo -r "Pi-hole: $pi_hole_ver" || (log_echo "Pi-hole git repository not detected." && error_found=1) cd "${PIHOLEGITDIR}"
local admin_ver="$(cd /var/www/html/admin && git describe --tags --abbrev=0)" \ pi_hole_ver=$(git describe --tags --abbrev=0)
&& log_echo -r "WebUI: $admin_ver" || (log_echo "Pi-hole Admin Pages git repository not detected." && error_found=1) pi_hole_branch=$(git rev-parse --abbrev-ref HEAD)
local light_ver="$(lighttpd -v |& head -n1 | cut -d " " -f1)" \ pi_hole_commit=$(git describe --long --dirty --tags --always)
&& log_echo -r "${light_ver}" || (log_echo "lighttpd not installed." && error_found=1) log_echo -r "Pi-hole: ${pi_hole_ver:-Untagged} (${pi_hole_branch:-Detached}:${pi_hole_commit})"
local php_ver="$(php -v |& head -n1)" \ else
&& log_echo -r "${php_ver}" || (log_echo "PHP not installed." && error_found=1) log_echo "Pi-hole git repository not detected."
error_found=1
(local pi_hole_branch="$(cd /etc/.pihole/ && git rev-parse --abbrev-ref HEAD)" && log_echo -r "Pi-hole branch: ${pi_hole_branch}") || log_echo "Unable to obtain Pi-hole branch" fi
(local pi_hole_rev="$(cd /etc/.pihole/ && git describe --long --dirty --tags)" && log_echo -r "Pi-hole rev: ${pi_hole_rev}") || log_echo "Unable to obtain Pi-hole revision" if [[ -d "${ADMINGITDIR}" ]]; then
cd "${ADMINGITDIR}"
(local admin_branch="$(cd /var/www/html/admin && git rev-parse --abbrev-ref HEAD)" && log_echo -r "AdminLTE branch: ${admin_branch}") || log_echo "Unable to obtain AdminLTE branch" admin_ver=$(git describe --tags --abbrev=0)
(local admin_rev="$(cd /var/www/html/admin && git describe --long --dirty --tags)" && log_echo -r "AdminLTE rev: ${admin_rev}") || log_echo "Unable to obtain AdminLTE revision" admin_branch=$(git rev-parse --abbrev-ref HEAD)
admin_commit=$(git describe --long --dirty --tags --always)
log_echo -r "Web Dashboard: ${admin_ver:-Untagged} (${admin_branch:-Detached}:${admin_commit})"
else
log_echo "Pi-hole Admin Pages git repository not detected."
error_found=1
fi
if light_ver=$(lighttpd -v |& head -n1 | cut -d " " -f1); then
log_echo -r "${light_ver}"
else
log_echo "lighttpd not installed."
error_found=1
fi
if php_ver=$(php -v |& head -n1); then
log_echo -r "${php_ver}"
else
log_echo "PHP not installed."
error_found=1
fi
return "${error_found}" return "${error_found}"
} }