From af96ff8b180470a9962f4e3a50007ce092138d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 22 Mar 2024 22:26:40 +0100 Subject: [PATCH] Handle already existing data_dir --- scripts/install | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 3f7cf11..f210311 100644 --- a/scripts/install +++ b/scripts/install @@ -29,9 +29,22 @@ chown -R "$app:www-data" "$install_dir" #================================================= ynh_script_progression --message="Initializing data directory..." --weight=1 -mv "$install_dir/_data" "$data_dir/_data" -mv "$install_dir/upload" "$data_dir/upload" -mv "$install_dir/galleries" "$data_dir/galleries" +# Move data dirs to $data_dir unless they already exist +if [ -d "$install_dir/_data" ]; then + ynh_secure_remove "$install_dir/_data" +else + mv "$install_dir/_data" "$data_dir/_data" +fi +if [ -d "$install_dir/galleries" ]; then + ynh_secure_remove "$install_dir/galleries" +else + mv "$install_dir/galleries" "$data_dir/galleries" +fi +if [ -d "$install_dir/upload" ]; then + ynh_secure_remove "$install_dir/upload" +else + mv "$install_dir/upload" "$data_dir/upload" +fi chmod -R o-rwx "$data_dir" chown -R "$app:www-data" "$data_dir"