mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 06:48:07 +00:00
Version strings & bash.
Fixed up the version checking. Thanks for your help @dschaper. No longer uses the version string as returned, but uses the major and minor version numbers extracted from it, against the minimum of 5.5. Tested against real install of php 7.0, (and the version check logic separately tested against a variety of artificial version numbers, of multiple digits for both major and minor version. - Lesson learned, I'm never trusting bash again) Signed-off-by: Rob Gill <rrobgill@protonmail.com>
This commit is contained in:
parent
13b8e1a2ae
commit
a3569d88c9
@ -160,13 +160,19 @@ if command -v apt-get &> /dev/null; then
|
||||
# use iproute
|
||||
iproute_pkg="iproute"
|
||||
fi
|
||||
# Check for and determine version number, major and minor of current php install
|
||||
# Check for and determine version number (major and minor) of current php install
|
||||
if command -v php &> /dev/null; then
|
||||
phpInsVersion="$(php -v | head -n1 | grep -Po '(?<PHP )[^ ]+')"
|
||||
phpInsVersion="$(php -v | head -n1 | grep -Po '(?<=PHP )[^ ]+')"
|
||||
echo -e " ${INFO} Existing PHP installation detected : PHP version $phpInsVersion"
|
||||
phpInsMajor="$(echo "$phpInsVersion" | cut -d\. -f1)"
|
||||
phpInsMinor="$(echo "$phpInsVersion" | cut -d\. -f2)"
|
||||
# Is installed php version supported? (php 5.4 is EOL)
|
||||
if [ "$(echo "$phpInsMajor.$phpInsMinor < 5.5" | bc )" == 0 ]; then
|
||||
phpInsSupported=true
|
||||
fi
|
||||
fi
|
||||
# Check if installed php is supported version (5.4 is EOL)
|
||||
if [[ "$phpInsVersion" < "5.5" ]]; then
|
||||
# Check if installed php is unsupported version (5.4 is EOL)
|
||||
if [[ "$phpInsSupported" != true ]]; then
|
||||
# Prefer the php metapackage if it's there
|
||||
if ${PKG_MANAGER} install --dry-run php > /dev/null 2>&1; then
|
||||
phpVer="php"
|
||||
@ -176,8 +182,6 @@ if command -v apt-get &> /dev/null; then
|
||||
fi
|
||||
else
|
||||
# Supported php is installed, its common, cgi & sqlite counterparts are deps
|
||||
phpInsMajor="$(echo "$phpInsVersion" | cut -d\. -f1)"
|
||||
phpInsMinor="$(echo "$phpInsVersion" | cut -d\. -f2)"
|
||||
phpVer="php$phpInsMajor.$phpInsMinor"
|
||||
fi
|
||||
# We also need the correct version for `php-sqlite` (which differs across distros)
|
||||
|
Loading…
Reference in New Issue
Block a user