From c121bc187eeec6d17f0ac47fcdf2c4a49104ea07 Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 22 Jun 2022 15:05:04 +0200 Subject: [PATCH] install_roundcube.sh: fix some errors concerning use of blank seperated string var (does not work at all). Some such vars replaced by an array. --- install_roundcube.sh | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/install_roundcube.sh b/install_roundcube.sh index 7107b6e..4ef8555 100755 --- a/install_roundcube.sh +++ b/install_roundcube.sh @@ -417,7 +417,7 @@ if $PHP_DEBIAN_INSTALLATION ; then fi else 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` + IFS=$'\n' 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!" @@ -484,7 +484,16 @@ echo "" if $PHP_DEBIAN_INSTALLATION ; then echo -e "\tInstalled PHP version................: $php_major_version" else - echo -e "\tInstalled PHP versions...............: $php_major_versions" + declare -i index=1 + for _ver in $php_major_versions ; do + if [[ $index -eq 1 ]] ; then + echo -en "\tInstalled PHP versions...............: $_ver" + else + echo -en " $_ver" + fi + ((index++)) + done + echo "" echo -e "\tNewest PHP Version...................: $php_latest_ver" fi echo "" @@ -560,7 +569,7 @@ _log_dir=${_src_base_dir}/log-roundcube-$_version # - * Composer installed either locally or globally (https://getcomposer.org) -needed_php_pear_modules="" +declare -a needed_php_pear_module_arrs=() _needed_php_pear_modules=" MDB2 Mail_Mime @@ -571,13 +580,18 @@ _needed_php_pear_modules=" " for _module in $_needed_php_pear_modules ; do + [[ -n "$(trim $_module)" ]] && needed_php_pear_module_arrs+=("$(trim $_module)") _module="$(trim $_module)" needed_php_pear_modules="$needed_php_pear_modules $_module" + done if [[ "$DB_TYPE" = "pgsql" ]]; then + needed_php_pear_module_arrs+=("MDB2_Driver_pgsql") needed_php_pear_modules="$needed_php_pear_modules MDB2_Driver_pgsql" else + needed_php_pear_module_arrs+=("MDB2_Driver_mysql") + needed_php_pear_module_arrs+=("MDB2_Driver_mysqli") needed_php_pear_modules="$needed_php_pear_modules MDB2_Driver_mysql MDB2_Driver_mysqli" fi @@ -597,7 +611,8 @@ if $PHP_DEBIAN_INSTALLATION ; then error "$(cat $log_file)" fi - for _module in $needed_php_pear_modules ; do + #for _module in $needed_php_pear_modules ; do + for _module in "${needed_php_pear_module_arrs[@]}" ; do _module="$(trim $_module)" echononl "\tInstall Module '$_module'.." if ! pear list | grep -q "$_module" 2> /dev/null ; then @@ -635,7 +650,8 @@ else error "$(cat $log_file)" fi - for _module in $needed_php_pear_modules ; do + #for _module in $needed_php_pear_modules ; do + for _module in "${needed_php_pear_module_arrs[@]}" ; do _module="$(trim $_module)" echononl "\tInstall Module '$_module'.." @@ -723,13 +739,13 @@ echo -e "\n\n\t\033[37m\033[1mBase install Roundcube Webmail..\033[m\n" # - install roundcube # - echononl "\tDownload 'roundcubemail-${ROUNDCUBE_VERSION}'.." -if [[ ! -f "$_src_base_dir/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz" ]]; then +if [[ ! -s "$_src_base_dir/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz" ]] ; then wget -O ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz https://github.com/roundcube/roundcubemail/releases/download/${ROUNDCUBE_VERSION}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed - error "$(cat $log_file)" + fatal "$(cat $log_file)" fi else echo_skipped @@ -830,11 +846,11 @@ fi echononl "\tInstall PHP dependencies.." if $PHP_DEBIAN_INSTALLATION ; then su ${HTTP_USER} -c"cd ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION} - php /usr/local/bin/composer install --no-dev" -s /bin/bash \ + php /usr/local/bin/composer install --no-interaction --no-dev" -s /bin/bash \ > $log_file 2>&1 else su ${HTTP_USER} -c"cd ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION} - /usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer install --no-dev" -s /bin/bash \ + /usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer --no-interaction install --no-dev" -s /bin/bash \ > $log_file 2>&1 fi if [[ $? -eq 0 ]]; then @@ -2252,7 +2268,7 @@ fi #fi _key="managesieve_vacation" -_val="1" +_val="2" echononl "\tChange '$_key' to $_val" perl -i -n -p -e "s#(^\s*\\\$config\['$_key'\].*)#//\!\1\n\\\$config['$_key'] = $_val;#" \ ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/plugins/${_plugin}/config.inc.php > $log_file 2>&1