From 1f26e853998650d2d56b596b440ab71bd8773dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 13 Jun 2022 15:06:15 +0200 Subject: [PATCH 1/5] Exit installer if no valid PHP version is found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index bf0bc994..6956484d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -301,8 +301,13 @@ package_manager_detect() { local phpVer="php" if is_command php ; then printf " %b Existing PHP installation detected : PHP version %s\\n" "${INFO}" "$(php <<< "")" - printf -v phpInsMajor "%d" "$(php <<< "")" - printf -v phpInsMinor "%d" "$(php <<< "")" + printf -v phpInsMajor "$(php <<< "")" + printf -v phpInsMinor "$(php <<< "")" + if [[ "$phpInsMajor" =~ [^[:digit:]] || "$phpInsMinor" =~ [^[:digit:]] ]]; then + printf " %b No valid PHP version detected\\n" "${CROSS}" + # so exit the installer + exit + fi phpVer="php$phpInsMajor.$phpInsMinor" fi # Packages required to perfom the os_check (stored as an array) From 7d731870e541897e20077a10b10b197627aaf847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 13 Jun 2022 16:06:59 +0200 Subject: [PATCH 2/5] Fix stickler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6956484d..a5c2d2f6 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -301,8 +301,8 @@ package_manager_detect() { local phpVer="php" if is_command php ; then printf " %b Existing PHP installation detected : PHP version %s\\n" "${INFO}" "$(php <<< "")" - printf -v phpInsMajor "$(php <<< "")" - printf -v phpInsMinor "$(php <<< "")" + printf -v phpInsMajor "%s" "$(php <<< "")" + printf -v phpInsMinor "%s" "$(php <<< "")" if [[ "$phpInsMajor" =~ [^[:digit:]] || "$phpInsMinor" =~ [^[:digit:]] ]]; then printf " %b No valid PHP version detected\\n" "${CROSS}" # so exit the installer From 5818f3f997207f73eeeefa8ceda6f92b170ae612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 14 Jun 2022 00:05:27 +0200 Subject: [PATCH 3/5] Check for validity first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a5c2d2f6..9186eee2 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -298,17 +298,21 @@ package_manager_detect() { # Update package cache update_package_cache || exit 1 # Check for and determine version number (major and minor) of current php install - local phpVer="php" + local phpVer if is_command php ; then - printf " %b Existing PHP installation detected : PHP version %s\\n" "${INFO}" "$(php <<< "")" - printf -v phpInsMajor "%s" "$(php <<< "")" - printf -v phpInsMinor "%s" "$(php <<< "")" - if [[ "$phpInsMajor" =~ [^[:digit:]] || "$phpInsMinor" =~ [^[:digit:]] ]]; then - printf " %b No valid PHP version detected\\n" "${CROSS}" - # so exit the installer - exit + phpVer="$(php -v 2> /dev/null | head -n1 | cut -d '-' -f1 | cut -d ' ' -f2)" + # Check if the first character of the string is numeric + if [[ ${phpVer:0:1} =~ [1-9] ]]; then + printf " %b Existing PHP installation detected : PHP version %s\\n" "${INFO}" "${phpVer}" + printf -v phpInsMajor "%d" "$(php <<< "")" + printf -v phpInsMinor "%d" "$(php <<< "")" + phpVer="php$phpInsMajor.$phpInsMinor" + else + printf " %b No valid PHP installation detected!\\n" "${CROSS}" + printf " %b PHP version : %s\\n" "${INFO}" "${phpVer}" + printf " %b Aborting installation.\\n" "${CROSS}" + exit 1 fi - phpVer="php$phpInsMajor.$phpInsMinor" fi # Packages required to perfom the os_check (stored as an array) OS_CHECK_DEPS=(grep dnsutils) From 4b674ecfe3c6c2ab0c44a69285b17e709ee9c7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 14 Jun 2022 00:58:10 +0200 Subject: [PATCH 4/5] Fix first install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 9186eee2..0c5c21ce 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -298,7 +298,7 @@ package_manager_detect() { # Update package cache update_package_cache || exit 1 # Check for and determine version number (major and minor) of current php install - local phpVer + local phpVer="php" if is_command php ; then phpVer="$(php -v 2> /dev/null | head -n1 | cut -d '-' -f1 | cut -d ' ' -f2)" # Check if the first character of the string is numeric From ed8c6c04d4e9ae70364d4ff1447cf185bf5fea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 14 Jun 2022 23:04:31 +0200 Subject: [PATCH 5/5] Use PHP_VERSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 0c5c21ce..f9ec9505 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -300,7 +300,7 @@ package_manager_detect() { # Check for and determine version number (major and minor) of current php install local phpVer="php" if is_command php ; then - phpVer="$(php -v 2> /dev/null | head -n1 | cut -d '-' -f1 | cut -d ' ' -f2)" + phpVer="$(php <<< "")" # Check if the first character of the string is numeric if [[ ${phpVer:0:1} =~ [1-9] ]]; then printf " %b Existing PHP installation detected : PHP version %s\\n" "${INFO}" "${phpVer}"