Compare commits
3 Commits
2a987db4be
...
683dd33827
| Author | SHA1 | Date | |
|---|---|---|---|
| 683dd33827 | |||
| b3a8a719d8 | |||
|
|
ec8df55f0d |
@@ -10,32 +10,32 @@
|
|||||||
|
|
||||||
function get_local_branch() {
|
function get_local_branch() {
|
||||||
# Return active branch
|
# Return active branch
|
||||||
cd "${1}" 2>/dev/null || return 1
|
cd "${1}" 2>/dev/null || { echo "null"; return; }
|
||||||
git rev-parse --abbrev-ref HEAD || return 1
|
git rev-parse --abbrev-ref HEAD || echo "null"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_local_version() {
|
function get_local_version() {
|
||||||
# Return active version
|
# Return active version
|
||||||
cd "${1}" 2>/dev/null || return 1
|
cd "${1}" 2>/dev/null || { echo "null"; return; }
|
||||||
git describe --tags --always 2>/dev/null || return 1
|
git describe --tags --always 2>/dev/null || echo "null"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_local_hash() {
|
function get_local_hash() {
|
||||||
cd "${1}" 2>/dev/null || return 1
|
cd "${1}" 2>/dev/null || { echo "null"; return; }
|
||||||
git rev-parse --short=8 HEAD || return 1
|
git rev-parse --short=8 HEAD || echo "null"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_remote_version() {
|
function get_remote_version() {
|
||||||
# if ${2} is = "master" we need to use the "latest" endpoint, otherwise, we simply return null
|
# if ${2} is = "master" we need to use the "latest" endpoint, otherwise, we simply return null
|
||||||
if [[ "${2}" == "master" ]]; then
|
if [[ "${2}" == "master" ]]; then
|
||||||
curl -s "https://api.github.com/repos/pi-hole/${1}/releases/latest" 2>/dev/null | jq --raw-output .tag_name || return 1
|
curl -s "https://api.github.com/repos/pi-hole/${1}/releases/latest" 2>/dev/null | jq --raw-output .tag_name || echo "null"
|
||||||
else
|
else
|
||||||
echo "null"
|
echo "null"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_remote_hash() {
|
function get_remote_hash() {
|
||||||
git ls-remote "https://github.com/pi-hole/${1}" --tags "${2}" | awk '{print substr($0, 1,8);}' || return 1
|
git ls-remote "https://github.com/pi-hole/${1}" --tags "${2}" | awk '{print substr($0, 1,8);}' || echo "null"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Source the utils file for addOrEditKeyValPair()
|
# Source the utils file for addOrEditKeyValPair()
|
||||||
|
|||||||
@@ -13,14 +13,23 @@ cachedVersions="/etc/pihole/versions"
|
|||||||
|
|
||||||
if [ -f ${cachedVersions} ]; then
|
if [ -f ${cachedVersions} ]; then
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
. "$cachedVersions"
|
. "${cachedVersions}"
|
||||||
else
|
else
|
||||||
echo "Could not find /etc/pihole/versions. Running update now."
|
echo "Could not find /etc/pihole/versions. Running update now."
|
||||||
pihole updatechecker
|
pihole updatechecker
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
. "$cachedVersions"
|
. "${cachedVersions}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Convert "null" or empty values to "N/A" for display
|
||||||
|
normalize_version() {
|
||||||
|
if [ -z "${1}" ] || [ "${1}" = "null" ]; then
|
||||||
|
echo "N/A"
|
||||||
|
else
|
||||||
|
echo "${1}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local details
|
local details
|
||||||
details=false
|
details=false
|
||||||
@@ -33,21 +42,21 @@ main() {
|
|||||||
|
|
||||||
if [ "${details}" = true ]; then
|
if [ "${details}" = true ]; then
|
||||||
echo "Core"
|
echo "Core"
|
||||||
echo " Version is ${CORE_VERSION:=N/A} (Latest: ${GITHUB_CORE_VERSION:=N/A})"
|
echo " Version is $(normalize_version "${CORE_VERSION}") (Latest: $(normalize_version "${GITHUB_CORE_VERSION}"))"
|
||||||
echo " Branch is ${CORE_BRANCH:=N/A}"
|
echo " Branch is $(normalize_version "${CORE_BRANCH}")"
|
||||||
echo " Hash is ${CORE_HASH:=N/A} (Latest: ${GITHUB_CORE_HASH:=N/A})"
|
echo " Hash is $(normalize_version "${CORE_HASH}") (Latest: $(normalize_version "${GITHUB_CORE_HASH}"))"
|
||||||
echo "Web"
|
echo "Web"
|
||||||
echo " Version is ${WEB_VERSION:=N/A} (Latest: ${GITHUB_WEB_VERSION:=N/A})"
|
echo " Version is $(normalize_version "${WEB_VERSION}") (Latest: $(normalize_version "${GITHUB_WEB_VERSION}"))"
|
||||||
echo " Branch is ${WEB_BRANCH:=N/A}"
|
echo " Branch is $(normalize_version "${WEB_BRANCH}")"
|
||||||
echo " Hash is ${WEB_HASH:=N/A} (Latest: ${GITHUB_WEB_HASH:=N/A})"
|
echo " Hash is $(normalize_version "${WEB_HASH}") (Latest: $(normalize_version "${GITHUB_WEB_HASH}"))"
|
||||||
echo "FTL"
|
echo "FTL"
|
||||||
echo " Version is ${FTL_VERSION:=N/A} (Latest: ${GITHUB_FTL_VERSION:=N/A})"
|
echo " Version is $(normalize_version "${FTL_VERSION}") (Latest: $(normalize_version "${GITHUB_FTL_VERSION}"))"
|
||||||
echo " Branch is ${FTL_BRANCH:=N/A}"
|
echo " Branch is $(normalize_version "${FTL_BRANCH}")"
|
||||||
echo " Hash is ${FTL_HASH:=N/A} (Latest: ${GITHUB_FTL_HASH:=N/A})"
|
echo " Hash is $(normalize_version "${FTL_HASH}") (Latest: $(normalize_version "${GITHUB_FTL_HASH}"))"
|
||||||
else
|
else
|
||||||
echo "Core version is ${CORE_VERSION:=N/A} (Latest: ${GITHUB_CORE_VERSION:=N/A})"
|
echo "Core version is $(normalize_version "${CORE_VERSION}") (Latest: $(normalize_version "${GITHUB_CORE_VERSION}"))"
|
||||||
echo "Web version is ${WEB_VERSION:=N/A} (Latest: ${GITHUB_WEB_VERSION:=N/A})"
|
echo "Web version is $(normalize_version "${WEB_VERSION}") (Latest: $(normalize_version "${GITHUB_WEB_VERSION}"))"
|
||||||
echo "FTL version is ${FTL_VERSION:=N/A} (Latest: ${GITHUB_FTL_VERSION:=N/A})"
|
echo "FTL version is $(normalize_version "${FTL_VERSION}") (Latest: $(normalize_version "${GITHUB_FTL_VERSION}"))"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user