From a06c41db73f598fcfbeac8242116e65c505933e8 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Thu, 30 Mar 2023 22:54:26 +0200 Subject: [PATCH] fix data_dir --- manifest.toml | 5 +++-- scripts/install | 10 +++++----- scripts/restore | 10 +++++----- scripts/upgrade | 23 ++++++++++++----------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/manifest.toml b/manifest.toml index 338943d..878ed21 100644 --- a/manifest.toml +++ b/manifest.toml @@ -62,9 +62,10 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] - owner = "__APP__:www-data" - + [resources.data_dir] + dir = "/home/yunohost.app/__APP__/data/" + owner = "__APP__:www-data" [resources.permissions] main.url = "/" diff --git a/scripts/install b/scripts/install index 9c8e64f..1b6b08a 100644 --- a/scripts/install +++ b/scripts/install @@ -45,12 +45,12 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -mkdir -p $data_dir/data -mkdir -p $data_dir/data/{static,media,music} +mkdir -p $data_dir/ +mkdir -p $data_dir/{static,media,music} -chmod 750 "$data_dir/data/" -chmod -R o-rwx "$data_dir/data/" -chown -R $app:www-data "$data_dir/data/" +chmod 750 "$data_dir/" +chmod -R o-rwx "$data_dir/" +chown -R $app:www-data "$data_dir/" #================================================= # ADD A CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 7b7f1d3..6563e9d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,13 +25,13 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$data_dir/data/" --not_mandatory +ynh_restore_file --origin_path="$data_dir/" --not_mandatory -mkdir -p $data_dir/data/{static,media,music} +mkdir -p $data_dir/{static,media,music} -chmod 750 "$data_dir/data/" -chmod -R o-rwx "$data_dir/data/" -chown -R $app:www-data "$data_dir/data/" +chmod 750 "$data_dir/" +chmod -R o-rwx "$data_dir/" +chown -R $app:www-data "$data_dir/" #================================================= # RESTORE THE NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 2ca3e8f..28b57ca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,18 +31,19 @@ ynh_systemd_action --action="stop" --service_name="${app}-worker" --log_path="sy #================================================= # If data_dir doesn't exist, create it -if [ -z "$data_dir/data/" ]; then +if [ -z "$data_dir/" ]; then # Do a full backup before moving datas yunohost backup create --apps $app + data_dir="/home/yunohost.app/${app}/data" ynh_script_progression --message="Moving datas to $data_dir..." --weight=1 - mkdir -p /home/yunohost.app/${app}/data - mkdir -p /home/yunohost.app/${app}/data/{static,media,music} + mkdir -p $data_dir + mkdir -p $data_dir/{static,media,music} - chmod 750 "/home/yunohost.app/${app}/data" - chmod -R o-rwx "/home/yunohost.app/${app}/data" - chown -R $app:www-data "/home/yunohost.app/${app}/data" + chmod 750 "$data_dir" + chmod -R o-rwx "$data_dir" + chown -R $app:www-data "$data_dir" ynh_backup_if_checksum_is_different --file="$install_dir/code/config/.env" mkdir -p $install_dir/config @@ -52,19 +53,19 @@ if [ -z "$data_dir/data/" ]; then ynh_delete_file_checksum --file="$install_dir/code/config/.env" if [ -d "$install_dir/code/data/static/" ]; then - rsync -a $install_dir/code/data/static/ "/home/yunohost.app/${app}/data/static/" + rsync -a $install_dir/code/data/static/ $data_dir/static/ fi if [ -d "$install_dir/media/" ]; then - rsync -a $install_dir/media/ "/home/yunohost.app/${app}/data/media/" + rsync -a $install_dir/media/ $data_dir/media/ fi if [ -d "$install_dir/code/data/media/" ]; then - rsync -a $install_dir/code/data/media/ "/home/yunohost.app/${app}/data/media/" + rsync -a $install_dir/code/data/media/ $data_dir/media/ fi if [ -d "$install_dir/import/" ]; then - rsync -a $install_dir/import/ "/home/yunohost.app/${app}/data/music/" + rsync -a $install_dir/import/ $data_dir/music/ fi if [ -d "$install_dir/code/data/music/" ]; then - rsync -a $install_dir/code/data/music/ "/home/yunohost.app/${app}/data/music/" + rsync -a $install_dir/code/data/music/ $data_dir/music/ fi ynh_secure_remove --file="$install_dir/code"