diff --git a/scripts/backup b/scripts/backup index 2ab0ac6..732ba88 100755 --- a/scripts/backup +++ b/scripts/backup @@ -27,7 +27,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -53,7 +52,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_print_info --message="Backing up php-fpm configuration..." --weight=1 -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index af13a50..b4637e3 100644 --- a/scripts/install +++ b/scripts/install @@ -84,8 +84,6 @@ ynh_setup_source --dest_dir="$final_path" # Create necessary files datadir=$final_path/documents touch $final_path/htdocs/conf/conf.php -mkdir -p $datadir -chmod go-w $datadir #================================================= # NGINX CONFIGURATION @@ -240,10 +238,12 @@ ynh_store_file_checksum --file="$final_path/htdocs/conf/conf.php" # SECURE FILES AND DIRECTORIES #================================================= -# Set permissions to app files +# Set permissions on app files chown -R root: "$final_path" -chown -R $app: "$datadir" chmod 644 "$final_path/htdocs/conf/conf.php" +mkdir -p "$datadir" +chown -R $app: "$datadir" +chmod go-w $datadir #================================================= # SETUP LOGROTATE @@ -261,8 +261,7 @@ ynh_script_progression --message="Configuring SSOwat..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + ynh_permission_update --permission "main" --add "visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 074d885..17cbdd6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -56,6 +56,12 @@ ynh_script_progression --message="Removing php-fpm configuration..." --weight=1 # Remove the dedicated php-fpm config ynh_remove_fpm_config +# 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 +fi + #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 0d1d453..f2b5234 100755 --- a/scripts/restore +++ b/scripts/restore @@ -29,7 +29,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$final_path/documents/ fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) @@ -79,7 +79,7 @@ chown -R root: $final_path #================================================= ynh_print_info --message="Reconfiguring PHP-FPM..." --weight=50 -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" @@ -101,6 +101,17 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ ynh_restore_file --origin_path="/etc/logrotate.d/$app" +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R root: "$final_path" +chmod 644 "$final_path/htdocs/conf/conf.php" +mkdir -p "$datadir" +chown -R $app: "$datadir" +chmod go-w $datadir + #================================================= # GENERIC FINALIZATION #================================================= @@ -108,7 +119,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= 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=php$YNH_PHP_VERSION-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a7a6823..e07fffe 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,7 +25,7 @@ language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) current_version=$(ynh_app_setting_get --app=$app --key=version) update_version=$(ynh_app_upstream_version "../manifest.json") -datadir=$final_path/documents +datadir=$final_path/documents/ fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) @@ -123,7 +123,7 @@ fi ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config YNH_PHP_VERSION #================================================= # CREATE DEDICATED USER @@ -138,13 +138,15 @@ 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" +fi + # Create a dedicated php-fpm config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" -# Delete existing ini configuration file (backward compatibility) -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 #================================================= # SPECIFIC UPGRADE @@ -213,7 +215,6 @@ ynh_use_logrotate --non-append #================================================= # Set permissions on app files -# Set permissions to app files chown -R root: "$final_path" chmod 644 "$final_path/htdocs/conf/conf.php" mkdir -p "$datadir"