From 32784cd514d09bfc2d50e5cb61775f54281bcc97 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 20:55:26 +0200 Subject: [PATCH] Fix rights --- scripts/install | 11 ++++------- scripts/remove | 1 - scripts/restore | 4 ++-- scripts/upgrade | 14 +++++++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/install b/scripts/install index fd38d02..c79d09f 100755 --- a/scripts/install +++ b/scripts/install @@ -126,7 +126,7 @@ ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -156,20 +156,17 @@ ynh_script_progression --message="Creating the data directory..." # Define app's data directory datadir="/home/yunohost.app/${app}" +ynh_app_setting_set --app=$app --key=datadir --value="$datadir" + # Create app folders mkdir -p "$datadir/" mkdir -p "$datadir/uploads/" mkdir -p "$datadir/static/" mkdir -p "$datadir/static/emoji/" -# Give permission to the datadir -chown -R "$app":"$app" "$datadir" - -ynh_app_setting_set --app=$app --key=datadir --value="$datadir" - chmod 750 "$datadir" chmod -R o-rwx "$datadir" -chown -R root:$app "$datadir" +chown -R $app:$app "$datadir" #================================================= # CREATE THE CONFIG DIRECTORY diff --git a/scripts/remove b/scripts/remove index 35443da..08946d4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -21,7 +21,6 @@ port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE diff --git a/scripts/restore b/scripts/restore index 8949aa1..bc4f658 100755 --- a/scripts/restore +++ b/scripts/restore @@ -78,7 +78,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION @@ -98,7 +98,7 @@ mkdir -p "$datadir/static/emoji/" chmod 750 "$datadir" chmod -R o-rwx "$datadir" -chown -R root:$app "$datadir" +chown -R $app:$app "$datadir" #================================================= # RESTORE THE CONFIG FILE diff --git a/scripts/upgrade b/scripts/upgrade index a34e10c..2d5cb99 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -189,6 +189,10 @@ then ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -218,9 +222,9 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # SPECIFIC UPGRADE #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Updating a config file..." config="/etc/$app/config.exs" @@ -231,9 +235,6 @@ ynh_backup_if_checksum_is_different --file="$config" #================================================= ynh_script_progression --message="Making upgrade..." -# Give permission to the final_path -chown -R "$app":"$app" "$final_path" - pushd $final_path/$app su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl migrate" popd @@ -246,6 +247,9 @@ ynh_script_progression --message="Storing the config file checksum..." # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config" +chmod 400 "$config" +chown $app:$app "$config" + #================================================= # SETUP SYSTEMD #=================================================