mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-18 20:10:56 +00:00
Prototype function for getting version of local repo
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
0341bd1758
commit
8831b22fc8
@ -14,8 +14,26 @@ current=false
|
|||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
DEFAULT="-1"
|
DEFAULT="-1"
|
||||||
PHVERSION=$(cd /etc/.pihole/ \
|
PHGITDIR="/etc/.pihole/"
|
||||||
&& git describe --tags --always)
|
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/ \
|
WEBVERSION=$(cd /var/www/html/admin/ \
|
||||||
&& git describe --tags --always)
|
&& git describe --tags --always)
|
||||||
|
|
||||||
@ -42,16 +60,18 @@ WEBHASHLATEST=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/commits/ma
|
|||||||
head -n1 | \
|
head -n1 | \
|
||||||
awk -F ' ' '{ print $2}' | \
|
awk -F ' ' '{ print $2}' | \
|
||||||
tr -cd '[[:alnum:]]._-')
|
tr -cd '[[:alnum:]]._-')
|
||||||
|
|
||||||
|
|
||||||
normalOutput() {
|
normalOutput() {
|
||||||
echo "::: Pi-hole version is ${PHVERSION} (Latest version is ${PHVERSIONLATEST:-${DEFAULT}})"
|
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() {
|
webOutput() {
|
||||||
for var in "$@"; do
|
for var in "$@"; do
|
||||||
case "${var}" in
|
case "${var}" in
|
||||||
"-l" | "--latest" ) echo "${WEBVERSIONLATEST:--1}";;
|
"-l" | "--latest" ) echo "${WEBVERSIONLATEST:-${DEFAULT}}";;
|
||||||
"-c" | "--current" ) echo "${WEBVERSION}";;
|
"-c" | "--current" ) echo "${WEBVERSION:-Untagged}";;
|
||||||
"-h" | "--hash" ) echo "${WEBHASH}";;
|
"-h" | "--hash" ) echo "${WEBHASH}";;
|
||||||
* ) echo "::: Invalid Option!"; exit 1;
|
* ) echo "::: Invalid Option!"; exit 1;
|
||||||
esac
|
esac
|
||||||
@ -61,7 +81,7 @@ webOutput() {
|
|||||||
coreOutput() {
|
coreOutput() {
|
||||||
for var in "$@"; do
|
for var in "$@"; do
|
||||||
case "${var}" in
|
case "${var}" in
|
||||||
"-l" | "--latest" ) echo "${PHVERSIONLATEST:--1}";;
|
"-l" | "--latest" ) echo "${PHVERSIONLATEST:-${DEFAULT}}";;
|
||||||
"-c" | "--current" ) echo "${PHVERSION}";;
|
"-c" | "--current" ) echo "${PHVERSION}";;
|
||||||
"-h" | "--hash" ) echo "${PHHASH}";;
|
"-h" | "--hash" ) echo "${PHHASH}";;
|
||||||
* ) echo "::: Invalid Option!"; exit 1;
|
* ) echo "::: Invalid Option!"; exit 1;
|
||||||
@ -87,6 +107,8 @@ EOM
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLocalPHVersion
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
normalOutput
|
normalOutput
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user