Fix error in determine PHP Version.

This commit is contained in:
Christoph 2021-11-14 23:14:35 +01:00
parent b2f47c8633
commit d9b31d6f6f

View File

@ -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"