From fb3559ea4a3cef2abdc9ca9903c1d6b06bc75fe2 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sat, 22 Feb 2020 18:33:10 +0100 Subject: [PATCH] Rename variable to YNH_PHP_VERSION --- conf/nginx.conf | 2 +- scripts/_common.sh | 6 +++--- scripts/_ynh_add_fpm_config | 4 ++-- scripts/backup | 2 +- scripts/change_url | 4 ++-- scripts/install | 10 +++++----- scripts/remove | 2 -- scripts/restore | 7 ++++--- scripts/upgrade | 15 +++++++-------- 9 files changed, 25 insertions(+), 27 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 08a19e5..8f2b3fb 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -83,7 +83,7 @@ location ^~ __PATH__/ { fastcgi_param modHeadersAvailable true; # Enable pretty urls fastcgi_param front_controller_active true; - fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__YNH_PHP_VERSION__-fpm-__NAME__.sock; fastcgi_intercept_errors on; fastcgi_request_buffering off; fastcgi_param REMOTE_USER $remote_user; diff --git a/scripts/_common.sh b/scripts/_common.sh index c654615..433d870 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,8 +5,8 @@ pkg_dependencies="imagemagick acl tar smbclient at" -php_version="7.2" -extra_pkg_dependencies="php${php_version}-bz2 php${php_version}-imap php${php_version}-smbclient php${php_version}-gmp php${php_version}-gd php${php_version}-json php${php_version}-intl php${php_version}-curl php${php_version}-apcu php${php_version}-redis php${php_version}-ldap php${php_version}-imagick php${php_version}-zip php${php_version}-mbstring php${php_version}-xml php${php_version}-mysql" +YNH_PHP_VERSION="7.3" +extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-smbclient php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql" #================================================= # EXPERIMENTAL HELPERS @@ -332,7 +332,7 @@ ynh_smart_mktemp () { elif is_there_enough_space /var; then local tmpdir=/var elif is_there_enough_space /; then - local tmpdir=/ + local tmpdir=/ elif is_there_enough_space /home; then local tmpdir=/home else diff --git a/scripts/_ynh_add_fpm_config b/scripts/_ynh_add_fpm_config index cfe2232..487c044 100644 --- a/scripts/_ynh_add_fpm_config +++ b/scripts/_ynh_add_fpm_config @@ -43,7 +43,7 @@ ynh_add_fpm_config () { fi # Configure PHP-FPM 7.0 by default - phpversion="${phpversion:-7.0}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" local fpm_config_dir="/etc/php/$phpversion/fpm" local fpm_service="php${phpversion}-fpm" @@ -75,7 +75,7 @@ ynh_add_fpm_config () { # Replace standard variables into the default file ynh_replace_string --match_string="^\[www\]" --replace_string="[$app]" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*listen = .*" --replace_string="listen = /var/run/php/php7.0-fpm-$app.sock" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*listen = .*" --replace_string="listen = /var/run/php/php$phpversion-fpm-$app.sock" --target_file="$finalphpconf" ynh_replace_string --match_string="^user = .*" --replace_string="user = $app" --target_file="$finalphpconf" ynh_replace_string --match_string="^group = .*" --replace_string="group = $app" --target_file="$finalphpconf" ynh_replace_string --match_string=".*chdir = .*" --replace_string="chdir = $final_path" --target_file="$finalphpconf" diff --git a/scripts/backup b/scripts/backup index 2c80fa1..68ae4ee 100755 --- a/scripts/backup +++ b/scripts/backup @@ -48,7 +48,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Backing up php-fpm configuration..." -ynh_backup --src_path="/etc/php/$php_version/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/change_url b/scripts/change_url index dbc7d66..1f92a0e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -63,7 +63,7 @@ then domain="$old_domain" path_url="$new_path" # Create a dedicated nginx config - ynh_add_nginx_config php_version + ynh_add_nginx_config YNH_PHP_VERSION fi # Change the domain for nginx @@ -84,7 +84,7 @@ ynh_script_progression --message="Applying Nextcloud specific modifications..." # Define a function to execute commands with `occ` exec_occ() { (cd "$final_path" && exec_as "$app" \ - php${php_version} occ --no-interaction --no-ansi "$@") + php${YNH_PHP_VERSION} occ --no-interaction --no-ansi "$@") } if [ $change_domain -eq 1 ] diff --git a/scripts/install b/scripts/install index 9cd9c40..e6b6c93 100755 --- a/scripts/install +++ b/scripts/install @@ -58,7 +58,7 @@ ynh_script_progression --message="Installing dependencies..." --weight=60 ynh_install_app_dependencies $pkg_dependencies -ynh_install_php --phpversion="$php_version" --package="$extra_pkg_dependencies" +ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" #================================================= # CREATE A MYSQL DATABASE @@ -102,7 +102,7 @@ then fi # Create a dedicated nginx config -ynh_add_nginx_config php_version +ynh_add_nginx_config YNH_PHP_VERSION #================================================= # CREATE DEDICATED USER @@ -118,7 +118,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Configuring php-fpm..." --weight=2 # Create a dedicated php-fpm config -ynh_add_fpm_config --phpversion="$php_version" +ynh_add_fpm_config --usage=medium --footprint=high #================================================= # SPECIFIC SETUP @@ -139,7 +139,7 @@ ynh_script_progression --message="Installing nextcloud..." --weight=30 # Define a function to execute commands with `occ` exec_occ() { (cd "$final_path" && exec_as "$app" \ - php$php_version occ --no-interaction --no-ansi "$@") + php$YNH_PHP_VERSION occ --no-interaction --no-ansi "$@") } # Set write access for the following commands @@ -275,7 +275,7 @@ exec_occ background:cron # POST-INSTALL MAINTENANCE #================================================= -(cd /tmp ; at now + 10 minutes <<< "(cd $final_path ; sudo -u $app php${php_version} occ db:add-missing-indices ; sudo -u $app php${php_version} occ db:convert-filecache-bigint -n) > /tmp/${app}_maintenance.log") +(cd /tmp ; at now + 10 minutes <<< "(cd $final_path ; sudo -u $app php${YNH_PHP_VERSION} occ db:add-missing-indices ; sudo -u $app php${YNH_PHP_VERSION} occ db:convert-filecache-bigint -n) > /tmp/${app}_maintenance.log") #================================================= # CONFIGURE THE HOOK FILE FOR USER CREATE diff --git a/scripts/remove b/scripts/remove index 2da18b5..9ea5c15 100755 --- a/scripts/remove +++ b/scripts/remove @@ -30,8 +30,6 @@ ynh_script_progression --message="Removing dependencies..." --weight=20 # Remove metapackage and its dependencies ynh_remove_app_dependencies -ynh_remove_php - #================================================= # REMOVE THE MYSQL DATABASE #================================================= diff --git a/scripts/restore b/scripts/restore index 233640c..3538a74 100755 --- a/scripts/restore +++ b/scripts/restore @@ -8,6 +8,7 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +source _ynh_add_fpm_config #================================================= # MANAGE SCRIPT FAILURE @@ -83,7 +84,7 @@ ynh_system_user_create --username=$app # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/$php_version/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION @@ -95,7 +96,7 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=60 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies -ynh_install_php --phpversion="$php_version" --package="$extra_pkg_dependencies" +ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" #================================================= # RESTORE THE CRON FILE @@ -171,7 +172,7 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= ynh_script_progression --message="Reloading nginx web server and php-fpm..." -ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=php${YNH_PHP_VERSION}-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 47d9a0c..4a72bde 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,8 +139,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=7 ynh_install_app_dependencies $pkg_dependencies -ynh_remove_php -ynh_install_php --phpversion="$php_version" --package="$extra_pkg_dependencies" +ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" #================================================= # STANDARD UPGRADE STEPS @@ -152,7 +151,7 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - ynh_backup_if_checksum_is_different --file="/etc/nginx/conf.d/$domain.d/$app.conf" # Delete current nginx configuration to be able to check if .well-known is already served. -ynh_remove_nginx_config +ynh_remove_nginx_config $YNH_PHP_VERSION ynh_app_setting_delete --app=$app --key="checksum__etc_nginx_conf.d_$domain.d_$app.conf" # Check if .well-known is available for this domain @@ -165,7 +164,7 @@ then fi # Create a dedicated nginx config -ynh_add_nginx_config php_version +ynh_add_nginx_config YNH_PHP_VERSION #================================================= # CREATE DEDICATED USER @@ -181,11 +180,11 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 # Create a dedicated php-fpm config -ynh_add_fpm_config --phpversion="$php_version" +ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --usage=medium --footprint=high # Delete existing ini configuration file (backward compatibility) -if [ -f /etc/php/$php_version/fpm/conf.d/20-$app.ini ]; then - ynh_secure_remove --file=/etc/php/$php_version/fpm/conf.d/20-$app.ini +if [ -f /etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini ]; then + ynh_secure_remove --file=/etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini fi #================================================= @@ -198,7 +197,7 @@ fi # Define a function to execute commands with `occ` exec_occ() { (cd "$final_path" && exec_as "$app" \ - php$php_version occ --no-interaction --no-ansi "$@") + php$YNH_PHP_VERSION occ --no-interaction --no-ansi "$@") } # Define a function to add an external storage