Query php directly for major and minor version id strings.

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
Dan Schaper 2018-11-01 05:59:14 -07:00
parent 0c892e6b3a
commit 9d2d45b473
No known key found for this signature in database
GPG Key ID: B4FF14C01CC08DC0
1 changed files with 3 additions and 4 deletions

View File

@ -166,10 +166,9 @@ if command -v apt-get &> /dev/null; then
fi
# 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 )[^ ]+')"
printf " %b Existing PHP installation detected : PHP version %s\\n" "${INFO}" "${phpInsVersion}"
printf -v phpInsMajor "%d" "${phpInsVersion%%.*}"
printf -v phpInsMinor "%d" "${phpInsVersion##*.}"
printf " %b Existing PHP installation detected : PHP version %s\\n" "${INFO}" "$(php <<< "<?php echo PHP_VERSION ?>")"
printf -v phpInsMajor "%d" "$(php <<< "<?php echo PHP_MAJOR_VERSION ?>")"
printf -v phpInsMinor "%d" "$(php <<< "<?php echo PHP_MINOR_VERSION ?>")"
# Is installed php version 7.0 or greater
if [ "${phpInsMajor}" -ge 7 ]; then
phpInsNewer=true