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:
authoryubiuser <ckoenig@posteo.de>2022-08-26 11:09:42 +0300
committerGitHub <noreply@github.com>2022-08-26 11:09:42 +0300
commitd6cfa57ef35cefd41a8f2723852df4702a74f55f (patch)
tree5a0232f0e17ac9a8f030067cbbe4c7d5053e5046
parent66eeee5548cda67433adcd4681c118218d8b2731 (diff)
parent49b9dc8888b399439cf983ae2796738882e83805 (diff)
Add jq as dependency and remove json_extract (#4878)
**What does this PR aim to accomplish?:** Adds `jq` as dependency and removes the now obsolete `json_extract` function. `jq` is a small dependency and adds powerfull json abilities. With `FTL v6` we will have a whole new json-based API where `jq` might be needed anyway. Also for `PADD` to interact with `FTL v6`, `jq` will be a requirement: https://github.com/pi-hole/PADD/pull/247 --- **By submitting this pull request, I confirm the following:** 1. I have read and understood the [contributors guide](https://docs.pi-hole.net/guides/github/contributing/), as well as this entire template. I understand which branch to base my commits and Pull Requests against. 2. I have commented my proposed changes within the code and I have tested my changes. 3. I am willing to help maintain this change if there are issues with it later. 4. It is compatible with the [EUPL 1.2 license](https://opensource.org/licenses/EUPL-1.1) 5. I have squashed any insignificant commits. ([`git rebase`](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)) --- - [x] I have read the above and my PR is ready for review. _Check this box to confirm_
-rwxr-xr-xadvanced/Scripts/updatecheck.sh25
-rwxr-xr-xautomated install/basic-install.sh4
2 files changed, 6 insertions, 23 deletions
diff --git a/advanced/Scripts/updatecheck.sh b/advanced/Scripts/updatecheck.sh
index 0c9f385e..37211cc6 100755
--- a/advanced/Scripts/updatecheck.sh
+++ b/advanced/Scripts/updatecheck.sh
@@ -8,23 +8,6 @@
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license.
-# Credit: https://stackoverflow.com/a/46324904
-function json_extract() {
- local key=$1
- local json=$2
-
- local string_regex='"([^"\]|\\.)*"'
- local number_regex='-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?'
- local value_regex="${string_regex}|${number_regex}|true|false|null"
- local pair_regex="\"${key}\"[[:space:]]*:[[:space:]]*(${value_regex})"
-
- if [[ ${json} =~ ${pair_regex} ]]; then
- echo $(sed 's/^"\|"$//g' <<< "${BASH_REMATCH[1]}")
- else
- return 1
- fi
-}
-
function get_local_branch() {
# Return active branch
cd "${1}" 2> /dev/null || return 1
@@ -61,19 +44,19 @@ if [[ "$2" == "remote" ]]; then
sleep 30
fi
- GITHUB_CORE_VERSION="$(json_extract tag_name "$(curl -s 'https://api.github.com/repos/pi-hole/pi-hole/releases/latest' 2> /dev/null)")"
+ GITHUB_CORE_VERSION="$(curl -s 'https://api.github.com/repos/pi-hole/pi-hole/releases/latest' 2> /dev/null | jq --raw-output .tag_name)"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_CORE_VERSION" "${GITHUB_CORE_VERSION}"
if [[ "${INSTALL_WEB_INTERFACE}" == true ]]; then
- GITHUB_WEB_VERSION="$(json_extract tag_name "$(curl -s 'https://api.github.com/repos/pi-hole/AdminLTE/releases/latest' 2> /dev/null)")"
+ GITHUB_WEB_VERSION="$(curl -s 'https://api.github.com/repos/pi-hole/AdminLTE/releases/latest' 2> /dev/null | jq --raw-output .tag_name)"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_WEB_VERSION" "${GITHUB_WEB_VERSION}"
fi
- GITHUB_FTL_VERSION="$(json_extract tag_name "$(curl -s 'https://api.github.com/repos/pi-hole/FTL/releases/latest' 2> /dev/null)")"
+ GITHUB_FTL_VERSION="$(curl -s 'https://api.github.com/repos/pi-hole/FTL/releases/latest' 2> /dev/null | jq --raw-output .tag_name)"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_FTL_VERSION" "${GITHUB_FTL_VERSION}"
if [[ "${PIHOLE_DOCKER_TAG}" ]]; then
- GITHUB_DOCKER_VERSION="$(json_extract tag_name "$(curl -s 'https://api.github.com/repos/pi-hole/docker-pi-hole/releases/latest' 2> /dev/null)")"
+ GITHUB_DOCKER_VERSION="$(curl -s 'https://api.github.com/repos/pi-hole/docker-pi-hole/releases/latest' 2> /dev/null | jq --raw-output .tag_name)"
addOrEditKeyValPair "${VERSION_FILE}" "GITHUB_DOCKER_VERSION" "${GITHUB_DOCKER_VERSION}"
fi
diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index 4d860d33..a51f5d9a 100755
--- a/automated install/basic-install.sh
+++ b/automated install/basic-install.sh
@@ -330,7 +330,7 @@ package_manager_detect() {
# Packages required to run this install script (stored as an array)
INSTALLER_DEPS=(git iproute2 dialog ca-certificates)
# Packages required to run Pi-hole (stored as an array)
- PIHOLE_DEPS=(cron curl iputils-ping psmisc sudo unzip idn2 libcap2-bin dns-root-data libcap2 netcat-openbsd procps)
+ PIHOLE_DEPS=(cron curl iputils-ping psmisc sudo unzip idn2 libcap2-bin dns-root-data libcap2 netcat-openbsd procps jq)
# Packages required for the Web admin interface (stored as an array)
# It's useful to separate this from Pi-hole, since the two repos are also setup separately
PIHOLE_WEB_DEPS=(lighttpd "${phpVer}-common" "${phpVer}-cgi" "${phpVer}-sqlite3" "${phpVer}-xml" "${phpVer}-intl")
@@ -360,7 +360,7 @@ package_manager_detect() {
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l || true"
OS_CHECK_DEPS=(grep bind-utils)
INSTALLER_DEPS=(git dialog iproute newt procps-ng which chkconfig ca-certificates)
- PIHOLE_DEPS=(cronie curl findutils sudo unzip libidn2 psmisc libcap nmap-ncat)
+ PIHOLE_DEPS=(cronie curl findutils sudo unzip libidn2 psmisc libcap nmap-ncat jq)
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo php-xml php-json php-intl)
LIGHTTPD_USER="lighttpd"
LIGHTTPD_GROUP="lighttpd"