Skip to content

Commit

Permalink
check version (#79)
Browse files Browse the repository at this point in the history
* check version
  • Loading branch information
ipitio authored Feb 29, 2024
1 parent 37e2a00 commit 598d8f0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions advanced/Scripts/piholeDebug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ HTML_DIRECTORY="/var/www/html"
WEB_GIT_DIRECTORY="${HTML_DIRECTORY}/admin"
SHM_DIRECTORY="/dev/shm"
ETC="/etc"
SPEEDTEST_GIT_DIRECTORY="/etc/pihole/speedtest"

# Files required by Pi-hole
# https://discourse.pi-hole.net/t/what-files-does-pi-hole-use/1684
Expand Down Expand Up @@ -345,6 +346,8 @@ check_component_versions() {
compare_local_version_to_git_version "${CORE_GIT_DIRECTORY}" "Core"
# Check the Web version, branch, and commit
compare_local_version_to_git_version "${WEB_GIT_DIRECTORY}" "Web"
# Check the Speedtest version, branch, and commit
compare_local_version_to_git_version "${SPEEDTEST_GIT_DIRECTORY}" "Speedtest"
# Check the FTL version
check_ftl_version
}
Expand Down
3 changes: 3 additions & 0 deletions advanced/Scripts/speedtestmod/mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ install() {
$PKG_MANAGER install -y "${missingPkgs[@]}"
fi

download $etc_dir speedtest https://github.com/arevindh/pihole-speedtest
download $etc_dir mod https://github.com/arevindh/pi-hole
download $admin_dir admin https://github.com/arevindh/AdminLTE web
if [ -f $curr_wp ]; then
Expand Down Expand Up @@ -209,6 +210,8 @@ uninstall() {
purge() {
rm -rf "$admin_dir"/*_admin
rm -rf $opt_dir/speedtestmod
rm -rf $etc_dir/speedtest
rm -rf $etc_dir/mod
if [ -f /etc/systemd/system/pihole-speedtest.timer ]; then
rm -f /etc/systemd/system/pihole-speedtest.service
rm -f /etc/systemd/system/pihole-speedtest.timer
Expand Down
22 changes: 20 additions & 2 deletions advanced/Scripts/updatecheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ function get_local_hash() {
}

function get_remote_version() {
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/arevindh/${1}/releases/latest" 2> /dev/null | jq --raw-output .tag_name || { curl -s "https://api.github.com/repos/pi-hole/${1}/releases/latest" 2> /dev/null | jq --raw-output .tag_name || return 1; }
}


function get_remote_hash(){
git ls-remote "https://github.com/pi-hole/${1}" --tags "${2}" | awk '{print substr($0, 0,8);}' || return 1
git ls-remote "https://github.com/arevindh/${1}" --tags "${2}" | awk '{print substr($0, 0,8);}' || { git ls-remote "https://github.com/pi-hole/${1}" --tags "${2}" | awk '{print substr($0, 0,8);}' || return 1; }
}

# Source the setupvars config file
Expand Down Expand Up @@ -131,3 +131,21 @@ if [[ "${DOCKER_TAG}" ]]; then
GITHUB_DOCKER_VERSION="$(get_remote_version docker-pi-hole)"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_DOCKER_VERSION" "${GITHUB_DOCKER_VERSION}"
fi


# get Speedtest versions

SPEEDTEST_VERSION="$(get_local_version /etc/pihole/speedtest)"
addOrEditKeyValPair "${VERSION_FILE}" "SPEEDTEST_VERSION" "${SPEEDTEST_VERSION}"

SPEEDTEST_BRANCH="$(get_local_branch /etc/pihole/speedtest)"
addOrEditKeyValPair "${VERSION_FILE}" "SPEEDTEST_BRANCH" "${SPEEDTEST_BRANCH}"

SPEEDTEST_HASH="$(get_local_hash /etc/pihole/speedtest)"
addOrEditKeyValPair "${VERSION_FILE}" "SPEEDTEST_HASH" "${SPEEDTEST_HASH}"

GITHUB_SPEEDTEST_VERSION="$(get_remote_version pihole-speedtest)"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_SPEEDTEST_VERSION" "${GITHUB_SPEEDTEST_VERSION}"

GITHUB_SPEEDTEST_HASH="$(get_remote_hash pihole-speedtest "${SPEEDTEST_BRANCH}")"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_SPEEDTEST_HASH" "${GITHUB_SPEEDTEST_HASH}"
6 changes: 6 additions & 0 deletions advanced/Scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ getLocalVersion() {
"Pi-hole" ) echo "${CORE_VERSION:=N/A}";;
"web" ) [ "${INSTALL_WEB_INTERFACE}" = true ] && echo "${WEB_VERSION:=N/A}";;
"FTL" ) echo "${FTL_VERSION:=N/A}";;
"speedtest" ) echo "${SPEEDTEST_VERSION:=N/A}";;
esac
}

Expand All @@ -38,6 +39,7 @@ getLocalHash() {
"Pi-hole" ) echo "${CORE_HASH:=N/A}";;
"web" ) [ "${INSTALL_WEB_INTERFACE}" = true ] && echo "${WEB_HASH:=N/A}";;
"FTL" ) echo "${FTL_HASH:=N/A}";;
"speedtest" ) echo "${SPEEDTEST_HASH:=N/A}";;
esac
}

Expand All @@ -46,6 +48,7 @@ getRemoteHash(){
"Pi-hole" ) echo "${GITHUB_CORE_HASH:=N/A}";;
"web" ) [ "${INSTALL_WEB_INTERFACE}" = true ] && echo "${GITHUB_WEB_HASH:=N/A}";;
"FTL" ) echo "${GITHUB_FTL_HASH:=N/A}";;
"speedtest" ) echo "${GITHUB_SPEEDTEST_HASH:=N/A}";;
esac
}

Expand All @@ -54,6 +57,7 @@ getRemoteVersion(){
"Pi-hole" ) echo "${GITHUB_CORE_VERSION:=N/A}";;
"web" ) [ "${INSTALL_WEB_INTERFACE}" = true ] && echo "${GITHUB_WEB_VERSION:=N/A}";;
"FTL" ) echo "${GITHUB_FTL_VERSION:=N/A}";;
"speedtest" ) echo "${GITHUB_SPEEDTEST_VERSION:=N/A}";;
esac
}

Expand Down Expand Up @@ -132,6 +136,7 @@ Repositories:
-p, --pihole Only retrieve info regarding Pi-hole repository
-a, --admin Only retrieve info regarding web repository
-f, --ftl Only retrieve info regarding FTL repository
-s, --speedtest Only retrieve info regarding Speedtest repository
Options:
-c, --current Return the current version
Expand All @@ -145,6 +150,7 @@ case "${1}" in
"-p" | "--pihole" ) shift; versionOutput "Pi-hole" "$@";;
"-a" | "--admin" ) shift; versionOutput "web" "$@";;
"-f" | "--ftl" ) shift; versionOutput "FTL" "$@";;
"-s" | "--speedtest" ) shift; versionOutput "speedtest" "$@";;
"-h" | "--help" ) helpFunc;;
* ) defaultOutput "$@";;
esac

0 comments on commit 598d8f0

Please sign in to comment.