Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Schaper <dan.schaper@pi-hole.net>2017-03-04 08:36:38 +0300
committerDan Schaper <dan.schaper@pi-hole.net>2017-03-04 08:36:38 +0300
commit8831b22fc89a0aba2cf75c5cd86644ac760a301f (patch)
treec2126cf0f549953ad9ed02b938daef0798569815
parent0341bd175871f2e6bdc6dce5c3ca8c0aa500f2b6 (diff)
Prototype function for getting version of local repo
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
-rwxr-xr-xadvanced/Scripts/version.sh34
1 files changed, 28 insertions, 6 deletions
diff --git a/advanced/Scripts/version.sh b/advanced/Scripts/version.sh
index b8876fc8..3bd9d4d2 100755
--- a/advanced/Scripts/version.sh
+++ b/advanced/Scripts/version.sh
@@ -14,8 +14,26 @@ current=false
# Variables
DEFAULT="-1"
-PHVERSION=$(cd /etc/.pihole/ \
- && git describe --tags --always)
+PHGITDIR="/etc/.pihole/"
+WEBGITDIR="/var/www/html/admin/"
+
+getLocalPHVersion(){
+ # Get the tagged version of the local Pi-hole repository
+ local version
+
+ cd "${PHGITDIR}" || { PHVERSION="${DEFAULT}"; return -1; }
+ version=$(git describe --tags --always || \
+ echo "${DEFAULT}")
+ if [[ "${version}" =~ ^v ]]; then
+ PHVERSION="${version}"
+ elif [[ "${version}" == "-1" ]]; then
+ PHVERSION="ERROR"
+ else
+ PHVERSION="Untagged"
+ fi
+ return 0
+}
+
WEBVERSION=$(cd /var/www/html/admin/ \
&& git describe --tags --always)
@@ -42,16 +60,18 @@ WEBHASHLATEST=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/commits/ma
head -n1 | \
awk -F ' ' '{ print $2}' | \
tr -cd '[[:alnum:]]._-')
+
+
normalOutput() {
echo "::: Pi-hole version is ${PHVERSION} (Latest version is ${PHVERSIONLATEST:-${DEFAULT}})"
- echo "::: Web-Admin version is ${WEBVERSION} (Latest version is ${WEBVERSIONLATEST:-${DEFAULT}})"
+ echo "::: Web-Admin version is ${WEBVERSION:-Untagged} (Latest version is ${WEBVERSIONLATEST:-${DEFAULT}})"
}
webOutput() {
for var in "$@"; do
case "${var}" in
- "-l" | "--latest" ) echo "${WEBVERSIONLATEST:--1}";;
- "-c" | "--current" ) echo "${WEBVERSION}";;
+ "-l" | "--latest" ) echo "${WEBVERSIONLATEST:-${DEFAULT}}";;
+ "-c" | "--current" ) echo "${WEBVERSION:-Untagged}";;
"-h" | "--hash" ) echo "${WEBHASH}";;
* ) echo "::: Invalid Option!"; exit 1;
esac
@@ -61,7 +81,7 @@ webOutput() {
coreOutput() {
for var in "$@"; do
case "${var}" in
- "-l" | "--latest" ) echo "${PHVERSIONLATEST:--1}";;
+ "-l" | "--latest" ) echo "${PHVERSIONLATEST:-${DEFAULT}}";;
"-c" | "--current" ) echo "${PHVERSION}";;
"-h" | "--hash" ) echo "${PHHASH}";;
* ) echo "::: Invalid Option!"; exit 1;
@@ -87,6 +107,8 @@ EOM
exit 0
}
+getLocalPHVersion
+
if [[ $# = 0 ]]; then
normalOutput
fi