From 2a4fe9998bb1b4bdd2b86ea034426671707c285f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 22 May 2021 18:55:57 +0200 Subject: [PATCH] Fix --- scripts/remove | 8 ++++++++ scripts/restore | 9 +++------ scripts/upgrade | 19 ++++++++++++------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/remove b/scripts/remove index 2123569..0ccc587 100755 --- a/scripts/remove +++ b/scripts/remove @@ -36,6 +36,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 + +# Delete a system user +ynh_system_user_delete --username=$app + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 0885e6d..9444e11 100644 --- a/scripts/restore +++ b/scripts/restore @@ -50,12 +50,9 @@ ynh_script_progression --message="Restoring $app main directory..." --weight=2 ynh_restore_file --origin_path="$final_path" -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chown -R root: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index e3d475a..9d654d8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,6 +57,14 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -69,6 +77,10 @@ then ynh_setup_source --dest_dir="$final_path" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -77,13 +89,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions on app files -chown -R root: $final_path - #================================================= # RELOAD NGINX #=================================================