From 24de2d80e1668ebc69f71f4b59e2c7d344d1f43a Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 7 Nov 2017 03:51:23 +0100 Subject: [PATCH] Determin PHP version if installed via debian packages system. --- install_roundcube.sh | 34 ++++++++++++++++++++++------------ upgrade_roundcube.sh | 9 ++++----- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/install_roundcube.sh b/install_roundcube.sh index 02a7243..9bd5382 100755 --- a/install_roundcube.sh +++ b/install_roundcube.sh @@ -175,9 +175,6 @@ if [ -x "$httpd_binary" ];then # - HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP # - Is webserver running ? # - @@ -188,6 +185,9 @@ if [ -x "$httpd_binary" ];then IS_HTTPD_RUNNING=true fi fi + +[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER +[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP [[ -n "$WEBMASTER_EMAIL" ]] || fatal "E-Mail (WEBMASTER_EMAIL) for webmaster not present!" [[ -n "$WEBSITE_BASEDIR" ]] || WEBSITE_BASEDIR=$DEFAULT_WEBSITE_BASEDIR @@ -294,12 +294,16 @@ fi # - Determin PHP of all installed versions # - echononl "\tGet major version of all installed PHP versions" -php_major_versions=`find /usr/local/ -maxdepth 1 -mindepth 1 -type l -name "php-*" -print | cut -d "-" -f2 | sort` -if [[ -z "$php_major_versions" ]]; then - echo_failed - error "Getting major version of installed PHP versions failed! No installed PHP versiond found!" +if $PHP_DEBIAN_INSTALLATION ; then + php_major_version="$(php --version | head -1 | cut -d' ' -f2 | cut -d '-' -f1 | cut -d'.' -f1,2)" else - echo_ok + php_major_versions=`find /usr/local/ -maxdepth 1 -mindepth 1 -type l -name "php-*" -print | cut -d "-" -f2 | sort` + if [[ -z "$php_major_versions" ]]; then + echo_failed + error "Getting major version of installed PHP versions failed! No installed PHP versiond found!" + else + echo_ok + fi fi # - Get the latest PHP version @@ -357,8 +361,12 @@ echo -e "\tRoundcube TEMP Directory.............: $ROUNDCUBE_TMPDIR" echo -e "\tRoundcube LOG Directory..............: ${WEBSITE_BASEDIR}/logs" echo -e "\tType of PHP connection...............: $PHP_TYPE" echo "" -echo -e "\tInstalled PHP versions...............: $php_major_versions" -echo -e "\tNewest PHP Version...................: $php_latest_ver" +if $PHP_DEBIAN_INSTALLATION ; then + echo -e "\tInstalled PHP version................: $php_major_version" +else + echo -e "\tInstalled PHP versions...............: $php_major_versions" + echo -e "\tNewest PHP Version...................: $php_latest_ver" +fi echo "" if [[ "$DB_TYPE" = "mysql" ]]; then echo -e "\tDatabase type of Roundcube Database..: MySQL" @@ -1294,12 +1302,13 @@ elif [[ "$PHP_TYPE" = "php_fpm" ]]; then EOF if $PHP_DEBIAN_INSTALLATION ; then cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file - SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://127.0.0.1" + SetHandler "proxy:unix:/var/run/php$(echo $php_major_version | cut -d'.' -f1)-fpm.sock|fcgi://127.0.0.1" EOF else cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1" EOF + fi cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file @@ -1556,12 +1565,13 @@ elif [[ "$PHP_TYPE" = "php_fpm" ]]; then EOF if $PHP_DEBIAN_INSTALLATION ; then cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file - SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://127.0.0.1" + SetHandler "proxy:unix:/var/run/php$(echo $php_major_version | cut -d'.' -f1)-fpm.sock|fcgi://127.0.0.1" EOF else cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1" EOF + fi cat <> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file diff --git a/upgrade_roundcube.sh b/upgrade_roundcube.sh index ddae2b3..f74569f 100755 --- a/upgrade_roundcube.sh +++ b/upgrade_roundcube.sh @@ -355,7 +355,7 @@ fi # - echononl "\tGet major version of all installed PHP versions" if $PHP_DEBIAN_INSTALLATION ; then - echo_skipped + php_major_version="$(php --version | head -1 | cut -d' ' -f2 | cut -d '-' -f1 | cut -d'.' -f1,2)" else php_major_versions="$(find /usr/local/ -maxdepth 1 -mindepth 1 -type l -name "php-*" -print | cut -d "-" -f2 | sort)" if [[ -z "$php_major_versions" ]]; then @@ -548,10 +548,9 @@ if [[ -n "$php_major_versions" ]]; then done else if $PHP_DEBIAN_INSTALLATION ; then - if [[ -f "/etc/init.d/php5-fpm" ]] ; then - /etc/init.d/php5-fpm start > $log_file 2>&1 - elif [[ -f "/etc/init.d/php7-fpm" ]] ; then - /etc/init.d/php7-fpm start > $log_file 2>&1 + echononl " Start PHP FPM engine v${php_major_version}.." + if [[ -f "/etc/init.d/php$(echo $php_major_version | cut -d'.' -f1)-fpm" ]] ; then + /etc/init.d/php$(echo $php_major_version | cut -d'.' -f1)-fpm start > $log_file 2>&1 else echo_skipped fi