From af3617921d97b477c56011718d7742d9d5eaef86 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 24 May 2020 03:00:28 +0200 Subject: [PATCH] various corrections --- conf/nginx.conf | 4 ++-- scripts/_common.sh | 2 ++ scripts/backup | 2 +- scripts/change_url | 2 +- scripts/install | 12 ++++++------ scripts/remove | 9 --------- scripts/restore | 22 ++++++++++++---------- scripts/upgrade | 14 +++++++------- 8 files changed, 31 insertions(+), 36 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 0a825b1..f9fefba 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -58,7 +58,7 @@ location __PATH__/ { location ~ '[^/]\.php$|^/update.php' { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__YNH_PHP_VERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; @@ -90,4 +90,4 @@ location __PATH__/ { location @rewrite { rewrite ^/(.*)$ /index.php?q=$1; -} \ No newline at end of file +} diff --git a/scripts/_common.sh b/scripts/_common.sh index 98bdd1e..0fc0bdf 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,6 +7,8 @@ # dependencies used by the app pkg_dependencies="curl" +swap_needed=512 + YNH_PHP_VERSION="7.3" extra_php_dependencies="php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-simplexml php${YNH_PHP_VERSION}-curl" diff --git a/scripts/backup b/scripts/backup index 24f1b70..fb90b69 100644 --- a/scripts/backup +++ b/scripts/backup @@ -53,7 +53,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_print_info --message="Backing up php-fpm configuration..." -ynh_backup --src_path="/etc/php/$YNH_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 d4df89d..aef7dc5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -86,7 +86,7 @@ then domain="$old_domain" path_url="$new_path" # Create a dedicated nginx config - ynh_add_nginx_config YNH_PHP_VERSION + ynh_add_nginx_config fi # Change the domain for nginx diff --git a/scripts/install b/scripts/install index 73a1956..05e9c9a 100644 --- a/scripts/install +++ b/scripts/install @@ -95,7 +95,7 @@ ynh_setup_source --dest_dir="$final_path" ynh_print_info --message="Configuring nginx web server..." # Create a dedicated nginx config -ynh_add_nginx_config YNH_PHP_VERSION +ynh_add_nginx_config #================================================= # CREATE DEDICATED USER @@ -111,7 +111,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" ynh_print_info --message="Configuring php-fpm..." # Create a dedicated php-fpm config -ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_dependencies" +ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= # SPECIFIC SETUP @@ -120,7 +120,7 @@ ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_depende #================================================= ynh_print_info --message="Adding swap..." -ynh_add_swap --size=512 +ynh_add_swap --size=$swap_needed #================================================= # CREATE DRUSH ALIAS @@ -146,7 +146,7 @@ mkdir -p "$final_path/.composer" cp -f "../conf/composer.json" "$final_path/composer.json" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/composer.json" -ynh_install_composer --phpversion="$YNH_PHP_VERSION" --workdir="$final_path" +ynh_install_composer --phpversion="${YNH_PHP_VERSION}" --workdir="$final_path" export PATH="$final_path/vendor/bin:$PATH" @@ -157,13 +157,13 @@ ynh_print_info --message="Installing Drupal..." chown -R $app: $final_path -update-alternatives --set php /usr/bin/php$YNH_PHP_VERSION +update-alternatives --set php /usr/bin/php${YNH_PHP_VERSION} pushd "$final_path" sudo -u $app env PATH=$PATH drush site:install $install_profil --account-name=$admin --account-pass=$password --account-mail=$admin_mail --db-url=mysql://$db_user:$db_pwd@localhost/$db_name --site-name="$app" --locale=$language --yes popd -update-alternatives --set php /usr/bin/php7.0 +update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} #================================================= # SETUP THE CRON FILE diff --git a/scripts/remove b/scripts/remove index 827e79c..f07a4a6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -32,15 +32,6 @@ ynh_print_info --message="Removing the MySQL database..." # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name -#================================================= -# REMOVE PHP -#================================================= - -if [ "$(lsb_release --codename --short)" != "buster" ]; then - ynh_print_info --message="Removing php..." - ynh_remove_php -fi - #================================================= # REMOVE DEPENDENCIES #================================================= diff --git a/scripts/restore b/scripts/restore index 75489ae..89b26ac 100644 --- a/scripts/restore +++ b/scripts/restore @@ -77,6 +77,17 @@ ynh_print_info --message="Restoring user rights..." # Restore permissions on app files chown -R $app: $final_path +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_print_info --message="Restoring PHP-FPM configuration..." + +# Restore the file first, so it can have a backup if different +ynh_restore_file --origin_path="/etc/php/${YNH_PHP_VERSION}/fpm/pool.d/$app.conf" + +# Recreate a dedicated php-fpm config +ynh_add_fpm_config --package="$extra_php_dependencies" + #================================================= # SPECIFIC RESTORATION #================================================= @@ -96,15 +107,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_print_info --message="Restoring PHP-FPM configuration..." - -ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" - -ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_dependencies" - #================================================= # RESTORE THE CRON FILE #================================================= @@ -116,7 +118,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= ynh_print_info --message="Adding swap..." -ynh_add_swap --size=512 +ynh_add_swap --size=$swap_needed #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index fef47e3..645deed 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,7 @@ ynh_abort_if_errors ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config -ynh_add_nginx_config YNH_PHP_VERSION +ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES @@ -104,7 +104,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" ynh_print_info --message="Upgrading php-fpm configuration..." # Create a dedicated php-fpm config -ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_dependencies" +ynh_add_fpm_config --package="$extra_php_dependencies" #================================================= # SPECIFIC UPGRADE @@ -113,14 +113,14 @@ ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_depende #================================================= ynh_print_info --message="Adding swap..." -ynh_add_swap --size=512 +ynh_add_swap --size=$swap_needed #================================================= # UPGRADE COMPOSER #================================================= ynh_print_info --message="Upgrading Composer..." -ynh_install_composer --phpversion="$YNH_PHP_VERSION" --workdir="$final_path" +ynh_install_composer --phpversion="${YNH_PHP_VERSION}" --workdir="$final_path" export PATH="$final_path/vendor/bin:$PATH" @@ -131,7 +131,7 @@ ynh_print_info --message="Upgrading Drupal..." ynh_backup_if_checksum_is_different --file="$final_path/$app/sites/default/settings.php" -update-alternatives --set php /usr/bin/php$YNH_PHP_VERSION +update-alternatives --set php /usr/bin/php${YNH_PHP_VERSION} pushd "$final_path" sudo -u $app env PATH=$PATH drush @$app.prod state:set system.maintenance_mode 1 --input-format=integer @@ -142,7 +142,7 @@ pushd "$final_path" sudo -u $app env PATH=$PATH drush @$app.prod state:set system.maintenance_mode 0 --input-format=integer popd -update-alternatives --set php /usr/bin/php7.0 +update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -182,7 +182,7 @@ ynh_print_info --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway + # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi