mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-15 11:59:04 +00:00
Factor out variables from display.
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
ebfffea5dc
commit
9bb4a5fb25
1 changed files with 36 additions and 45 deletions
|
@ -12,40 +12,39 @@
|
||||||
latest=false
|
latest=false
|
||||||
current=false
|
current=false
|
||||||
|
|
||||||
|
# Variables
|
||||||
DEFAULT="-1"
|
DEFAULT="-1"
|
||||||
|
PHVERSION=$(cd /etc/.pihole/ \
|
||||||
|
&& git describe --tags --always)
|
||||||
|
WEBVERSION=$(cd /var/www/html/admin/ \
|
||||||
|
&& git describe --tags --always)
|
||||||
|
|
||||||
|
PHHASH=$(cd /etc/.pihole/ \
|
||||||
|
&& git rev-parse --short HEAD)
|
||||||
|
WEBHASH=$(cd /var/www/html/admin/ \
|
||||||
|
&& git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
PHVERSIONLATEST=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | \
|
||||||
|
grep -Po '"tag_name":.*?[^\\]",' | \
|
||||||
|
perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||||
|
WEBVERSIONLATEST=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | \
|
||||||
|
grep -Po '"tag_name":.*?[^\\]",' | \
|
||||||
|
perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
||||||
|
|
||||||
|
PHHASHLATEST=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/commits/master | \
|
||||||
|
grep sha | \
|
||||||
|
head -n1 | \
|
||||||
|
awk -F ' ' '{ print $2}' | \
|
||||||
|
tr -cd '[[:alnum:]]._-')
|
||||||
|
|
||||||
|
WEBHASHLATEST=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/commits/master | \
|
||||||
|
grep sha | \
|
||||||
|
head -n1 | \
|
||||||
|
awk -F ' ' '{ print $2}' | \
|
||||||
|
tr -cd '[[:alnum:]]._-')
|
||||||
normalOutput() {
|
normalOutput() {
|
||||||
piholeVersion=$(cd /etc/.pihole/ \
|
echo "::: Pi-hole version is ${PHVERSION} (Latest version is ${PHVERSIONLATEST:-${DEFAULT}})"
|
||||||
&& git describe --tags --always)
|
echo "::: Web-Admin version is ${WEBVERSION} (Latest version is ${WEBVERSIONLATEST:-${DEFAULT}})"
|
||||||
webVersion=$(cd /var/www/html/admin/ \
|
|
||||||
&& git describe --tags --always)
|
|
||||||
|
|
||||||
piholeHash=$(cd /etc/.pihole/ \
|
|
||||||
&& git rev-parse --short HEAD)
|
|
||||||
webHash=$(cd /var/www/html/admin/ \
|
|
||||||
&& git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | \
|
|
||||||
grep -Po '"tag_name":.*?[^\\]",' | \
|
|
||||||
perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
|
||||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | \
|
|
||||||
grep -Po '"tag_name":.*?[^\\]",' | \
|
|
||||||
perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
|
||||||
|
|
||||||
piholeHashLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/commits/master | \
|
|
||||||
grep sha | \
|
|
||||||
head -n1 | \
|
|
||||||
awk -F ' ' '{ print $2}' | \
|
|
||||||
tr -cd '[[:alnum:]]._-')
|
|
||||||
|
|
||||||
piholeHashLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/commits/master | \
|
|
||||||
grep sha | \
|
|
||||||
head -n1 | \
|
|
||||||
awk -F ' ' '{ print $2}' | \
|
|
||||||
tr -cd '[[:alnum:]]._-')
|
|
||||||
|
|
||||||
echo "::: Pi-hole version is ${piholeVersion} (Latest version is ${piholeVersionLatest:-${DEFAULT}})"
|
|
||||||
echo "::: Web-Admin version is ${webVersion} (Latest version is ${webVersionLatest:-${DEFAULT}})"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
webOutput() {
|
webOutput() {
|
||||||
|
@ -58,15 +57,11 @@ webOutput() {
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
if [[ "${latest}" == true && "${current}" == false ]]; then
|
||||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
echo "${WEBVERSIONLATEST:--1}"
|
||||||
echo "${webVersionLatest:--1}"
|
|
||||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
||||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
echo "${WEBVERSION}"
|
||||||
echo "${webVersion}"
|
|
||||||
else
|
else
|
||||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
echo "::: Web-Admin version is ${WEBVERSION} (Latest version is ${WEBVERSIONLATEST:-${DEFAULT}})"
|
||||||
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
|
||||||
echo "::: Web-Admin version is ${webVersion} (Latest version is ${webVersionLatest:-${DEFAULT}})"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,15 +75,11 @@ coreOutput() {
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
if [[ "${latest}" == true && "${current}" == false ]]; then
|
||||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
echo "${PHVERSIONLATEST:--1}"
|
||||||
echo "${piholeVersionLatest:--1}"
|
|
||||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
||||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
echo "${PHVERSION}"
|
||||||
echo "${piholeVersion}"
|
|
||||||
else
|
else
|
||||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
echo "::: Pi-hole version is ${PHVERSION} (Latest version is ${PHVERSIONLATEST:-${DEFAULT}})"
|
||||||
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
|
|
||||||
echo "::: Pi-hole version is ${piholeVersion} (Latest version is ${piholeVersionLatest:-${DEFAULT}})"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue