From d9b31d6f6fe65d020a71e3475794d3292e083109 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 14 Nov 2021 23:14:35 +0100 Subject: [PATCH] Fix error in determine PHP Version. --- update_nextcloud.sh | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/update_nextcloud.sh b/update_nextcloud.sh index df045ac..63d9b60 100755 --- a/update_nextcloud.sh +++ b/update_nextcloud.sh @@ -493,7 +493,7 @@ if [[ "$PHP_ENGINE" = "FPM" ]] ; then if $NGINX_IS_ENABLED ; then if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="" + VHOST_CONFIG_FILE="$(realpath "/etc/nginx/sites-enabled/${WEBSITE}.conf")" fi elif $APACHE2_IS_ENABLED ; then @@ -508,9 +508,42 @@ if [[ "$PHP_ENGINE" = "FPM" ]] ; then fi fi - PHP_VERSION="$(grep -o -E "php-?.{1}\..{1}-fpm" $VHOST_CONFIG_FILE | grep -o -E ".{1}\..{1}")" + if [[ -z "$VHOST_CONFIG_FILE" ]] ; then + PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" $VHOST_CONFIG_FILE \ + | grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")" + fi if [[ -z "$PHP_VERSION" ]] ; then - fatal "PHP Version must be givven if running PHP-FPM engine (parameter 'PHP_VERSION')" + + warn "The PHP version was not specified and cannot be determined!" + + main_version_regex="^[[:digit:]]{1,2}\.[[:digit:]]{1}$" + + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "Enter the PHP main version, e.g. 7.4 or 8.0 .." + echo "" + echo "" + PHP_VERSION= + while [ "X$PHP_VERSION" = "X" ] + do + echononl " PHP main version: " + read PHP_VERSION + if [ "X$PHP_VERSION" = "X" ]; then + echo "" + echo -e "\033[33m\033[1mInput is required !!\033[m" + echo "" + fi + if [[ ! $PHP_VERSION =~ $main_version_regex ]] ; then + echo "" + echo -e "\033[33m\033[1mWrong entry (${PHP_VERSION}) for main PHP version !!\033[m" + echo "" + PHP_VERSION= + fi + + done + + fi fi fi @@ -574,7 +607,7 @@ echo "" echo -e " New Installation directory...........: $INSTALL_DIR" echo -e " Old Installation directory...........: $CURRENT_INSTALL_DIR" echo "" -echo -e " Data directory........................: $DATA_DIR" +echo -e " Data directory.......................: $DATA_DIR" echo -e " Old Data directory...................: $OLD_DATA_DIR" echo "" echo -e " Source directory for tar archiv......: $SRC_BASE_DIR"