From d283c566e4e8b2d02d8cfbc51329661c9e7ee51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 24 Nov 2023 11:58:13 +0100 Subject: [PATCH] Move old data when data already exist --- scripts/install | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/install b/scripts/install index 9acee2f..e88b16d 100644 --- a/scripts/install +++ b/scripts/install @@ -28,6 +28,13 @@ fi ynh_script_progression --message="Creating base directory..." ln -s $data_dir $install_dir/seafile-data +if [ -n "$(ls -A $data_dir)" ]; then + old_data_dir_path="${data_dir}_$(date '+%Y%m%d.%H%M%S')" + ynh_print_warn "Data directory was not empty. Data was moved to $old_data_dir_path" + mkdir -p $old_data_dir_path + mv -t "$old_data_dir_path" "$data_dir"/* +fi + # Download new version from sources ynh_script_progression --message="Installing sources files..." --weight=7 ynh_setup_source --dest_dir=$install_dir/seafile-server-$seafile_version