From 166ae0ae41770177a880534cdd8af2763bd4c83e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 2 Nov 2020 17:47:49 +0100 Subject: [PATCH] Add suport for PHP7.3 --- conf/nginx.conf | 1 + scripts/_common.sh | 32 +++++++++++++++++++++++--------- scripts/backup | 2 +- scripts/change_url | 2 +- scripts/install | 4 ++-- scripts/remove | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 10 +++++----- 8 files changed, 37 insertions(+), 22 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index bf1893d..7247307 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -39,6 +39,7 @@ location __PATH__/favicon.ico { location ~ ^__PATH__/(config|temp|logs)/ { deny all; } + location ~ ^__PATH__/(.+/|)\. { deny all; } diff --git a/scripts/_common.sh b/scripts/_common.sh index 46c06bd..4aa8607 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ YNH_PHP_VERSION="7.3" # Package dependencies -extra_php_dependencies="php-cli php-common php-intl php-json php-pear php-auth-sasl php-mail-mime php-patchwork-utf8 php-net-smtp php-net-socket php-zip php-gd php-mbstring php-curl" +extra_php_dependencies="php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-common php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-pear php${YNH_PHP_VERSION}-auth-sasl php${YNH_PHP_VERSION}-mail-mime php${YNH_PHP_VERSION}-patchwork-utf8 php${YNH_PHP_VERSION}-net-smtp php${YNH_PHP_VERSION}-net-socket php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-curl" # Plugins version contextmenu_version=2.3 @@ -18,9 +18,15 @@ carddav_version=3.0.3 # EXPERIMENTAL HELPERS #================================================= +readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17 +# Declare the actual composer version to use. +# A packager willing to use another version of composer can override the variable into its _common.sh. +YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION} + # Execute a command with Composer # -# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" +# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -c, --commands - Commands to execute. ynh_composer_exec () { @@ -33,7 +39,7 @@ ynh_composer_exec () { # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.3}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" COMPOSER_HOME="$workdir/.composer" \ php${phpversion} "$workdir/composer.phar" $commands \ @@ -42,25 +48,33 @@ ynh_composer_exec () { # Install and initialize Composer in the given directory # -# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] +# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion] +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include +# | arg: -c, --composerversion - Composer version to install ynh_install_composer () { # Declare an array to define the options of this helper. - local legacy_args=vw - declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) + local legacy_args=vwa + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=) local phpversion local workdir + local install_args + local composerversion # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.3}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" + install_args="${install_args:-}" + composerversion="${composerversion:-$YNH_COMPOSER_VERSION}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" \ + php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \ || ynh_die "Unable to install Composer." # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ || ynh_die "Unable to update core dependencies with Composer." } + diff --git a/scripts/backup b/scripts/backup index 0310c8b..6f4f9c1 100644 --- a/scripts/backup +++ b/scripts/backup @@ -62,4 +62,4 @@ ynh_mysql_dump_db --database="$db_name" > db.sql # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for Roundcube. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index e7b7425..8ae2680 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -89,4 +89,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for Roundcube" --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index c94866e..6736c01 100644 --- a/scripts/install +++ b/scripts/install @@ -117,7 +117,7 @@ ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name #================================================= # CONFIGURE ROUNDCUBE #================================================= -ynh_script_progression --message="Configuring Roundcube..." +ynh_script_progression --message="Configuring $app..." rc_conf="$final_path/config/config.inc.php" @@ -232,4 +232,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of Roundcube completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 579a922..c409dac 100644 --- a/scripts/remove +++ b/scripts/remove @@ -41,7 +41,7 @@ ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing Roundcube main directory..." --weight=3 +ynh_script_progression --message="Removing $app main directory..." --weight=3 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -76,4 +76,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of Roundcube completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 84b89a9..c9d43eb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -50,7 +50,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring Roundcube main directory..." +ynh_script_progression --message="Restoring $app main directory..." ynh_restore_file --origin_path="$final_path" @@ -104,4 +104,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for Roundcube" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index fb49838..0e49d0a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,7 +72,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up Roundcube before upgrading (may take a while)..." --weight=30 +ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=30 # Backup the current version of the app ynh_backup_before_upgrade @@ -152,7 +152,7 @@ then ynh_replace_string --match_string="__DBUSER__" --replace_string=$db_name --target_file="$rc_conf" db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$rc_conf" - ynh_replace_string --match_string="__DBNAME__" --replace_string=$db_name --target_file="$rc_conf" + ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$rc_conf" #================================================= # UPDATE DEPENDENCIES WITH COMPOSER @@ -241,7 +241,7 @@ then #================================================= # UPDATE ROUNDCUBE CONFIGURATION #================================================= - ynh_script_progression --message="Updating Roundcube configuration..." --weight=4 + ynh_script_progression --message="Updating $app configuration..." --weight=4 ynh_replace_string --match_string="^\s*// installed plugins" --replace_string="&\n $installed_plugins" --target_file="$rc_conf" @@ -255,7 +255,7 @@ then #================================================= # UPDATE ROUNDCUBE CORE #================================================= - ynh_script_progression --message="Updating Roundcube core..." --weight=4 + ynh_script_progression --message="Updating $app core..." --weight=4 ( cd "$final_path" ynh_exec_warn ./bin/update.sh --version=$oldversion -y) @@ -283,4 +283,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of Roundcube completed" --last +ynh_script_progression --message="Installation of $app completed" --last