From 2f027238ce47dbcedf2ec6024e48d142dacb0866 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 27 May 2021 09:31:10 +0200 Subject: [PATCH] Fix --- scripts/install | 7 ++++--- scripts/restore | 19 +++++++------------ scripts/upgrade | 42 +++++++++++++++++++++--------------------- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/scripts/install b/scripts/install index 5590248..e611173 100755 --- a/scripts/install +++ b/scripts/install @@ -95,8 +95,9 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_setup_source --dest_dir="$final_path" # Set permissions to app files -chown -R $app:$app $final_path -chmod -R 755 $files_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # CREATE DIRECTORIES @@ -104,8 +105,8 @@ chmod -R 755 $files_path files_path=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=files_path --value=$files_path - mkdir -p $files_path/files +chmod -R 755 $files_path #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 46f856b..fedd8b4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -53,13 +53,6 @@ test ! -d $final_path \ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -69,13 +62,15 @@ ynh_script_progression --message="Recreating the dedicated system user..." --wei ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 -# Restore permissions on app files -chown -R $app:$app $final_path -#chmod -R o-rwx $final_path -chmod 600 $final_path/config.json +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index eda136f..a43d900 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,6 +34,14 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +# If final_path doesn't exist, create it +if [ -z "$files_path" ]; then + files_path=/home/yunohost.app/$app + ynh_app_setting_set --app=$app --key=files_path --value=$files_path + mkdir -p $files_path/files + chmod -R 755 $files_path +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -64,6 +72,14 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=3 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -76,6 +92,11 @@ then ynh_setup_source --dest_dir="$final_path" --keep="$final_path/config.json" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod 600 $final_path/config.json + #================================================= # NGINX CONFIGURATION #================================================= @@ -91,14 +112,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=2 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=3 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # SETUP SYSTEMD #================================================= @@ -107,19 +120,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions on app files -chown -R $app:$app $final_path -chown -R $app:$app $files_path -#chmod -R o-rwx "$final_path" -chmod -R 755 $files_path -chmod 600 $final_path/config.json - #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================