if [[ "$PHP_ENGINE" = "FPM" ]] ; then if [[ -z "$PHP_VERSION" ]] ; then if [[ -z "$VHOST_CONFIG_FILE" ]] ; then if $NGINX_IS_ENABLED ; then if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then VHOST_CONFIG_FILE="$(realpath "/etc/nginx/sites-enabled/${WEBSITE}.conf")" fi elif $APACHE2_IS_ENABLED ; then if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf" fi fi fi if [[ -n "$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 if $NGINX_IS_ENABLED ; then upstream_handler="$(grep -o -E "^[^#]*fastcgi_pass\s+[^;]+" ${VHOST_CONFIG_FILE} | awk '{print$2}' )" for _file in $(ls /etc/nginx/conf.d/) ; do _rp_file="$(realpath "/etc/nginx/conf.d/${_file}")" if $(grep -q -E "\s+${upstream_handler}\s*" ${_rp_file} 2> /dev/null) ; then PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" ${_rp_file} \ | grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")" break fi done fi if [[ -z "$PHP_VERSION" ]] ; then warn "Cannot determin the PHP version\! Enter it manually" 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.2 .." 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 fi