diff --git a/scripts/install b/scripts/install index cc195a5..818cc2f 100644 --- a/scripts/install +++ b/scripts/install @@ -77,14 +77,6 @@ ynh_setup_source --dest_dir="$final_path" datadir=$final_path/documents touch $final_path/htdocs/conf/conf.php -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 - -# Create a dedicated nginx config -ynh_add_nginx_config - #================================================= # CREATE DEDICATED USER #================================================= @@ -99,7 +91,23 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Configuring PHP-FPM and install dependencies..." --weight=2 # Create a dedicated php-fpm config -ynh_add_fpm_config --usage=medium --footprint=medium --package="$extra_php_dependencies" +ynh_add_fpm_config --usage=medium --footprint=medium --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" + +# Used by ynh_add_nginx_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + +# If phpversion doesn't exist, create it +if [ -z "$phpversion" ]; then + phpversion="$YNH_PHP_VERSION" +fi + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 + +# Create a dedicated nginx config +ynh_add_nginx_config #================================================= # SPECIFIC SETUP diff --git a/scripts/restore b/scripts/restore index 72c9780..ddbcea2 100755 --- a/scripts/restore +++ b/scripts/restore @@ -73,9 +73,12 @@ ynh_system_user_create --username=$app #================================================= ynh_print_info --message="Reconfiguring PHP-FPM..." +# Restore the file first, so it can have a backup if different ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --package="$extra_php_dependencies" +# Recreate a dedicated php-fpm config +ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion --package="$extra_php_dependencies" + #================================================= # SPECIFIC RESTORATION @@ -112,8 +115,8 @@ chmod go-w $datadir #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index a4ee33b..8c624ef 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -78,6 +78,11 @@ if [ -z "$fpm_usage" ]; then ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage fi +# If phpversion doesn't exist, create it +if [ -z "$phpversion" ]; then + phpversion="$YNH_PHP_VERSION" +fi + if ! ynh_permission_exists --permission "public_space"; then ynh_permission_create --permission "public_space" --url "/public/" --allowed "visitors" fi @@ -131,13 +136,20 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 -# Delete old static pool.d conf -old_php_version=7.0 -if [ -f "/etc/php/$old_php_version/fpm/pool.d/$app.conf" ]; then - ynh_secure_remove --file="/etc/php/$old_php_version/fpm/pool.d/$app.conf" +# If php has changed, remove the old fpm config file +if [ "$phpversion" != $YNH_PHP_VERSION ] +then + ynh_backup_if_checksum_is_different --file="/etc/php/$phpversion/fpm/pool.d/$app.conf" + ynh_secure_remove --file="/etc/php/$phpversion/fpm/pool.d/$app.conf" + if [ -f /etc/php/$phpversion/fpm/conf.d/20-$app.ini ]; then + ynh_secure_remove --file="/etc/php/$phpversion/fpm/conf.d/20-$app.ini" + fi + ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload + + phpversion="$YNH_PHP_VERSION" fi -# Create a dedicated php-fpm config +# Recreate a dedicated PHP-FPM config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --package="$extra_php_dependencies" #================================================= @@ -213,12 +225,23 @@ mkdir -p "$datadir" chown -R $app: "$datadir" chmod go-w $datadir +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 + +# Create the public space permission if needed +if ! ynh_permission_exists --permission "public_space"; then + ynh_permission_create --permission "public_space" --url "/public/" --allowed "visitors" +fi + #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload #================================================= # END OF SCRIPT