From 639f679928a0914cfeeb07b072d1fbfc30ddd201 Mon Sep 17 00:00:00 2001 From: Anmol Date: Tue, 4 Jul 2017 00:51:48 +0530 Subject: [PATCH] copy data/ from old folder to new upgrade --- scripts/upgrade | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 1ce2d92..cb5eccb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,24 +15,25 @@ path_url=$(ynh_app_setting_get "$app" path) is_public=$(ynh_app_setting_get "$app" is_public) -# Copy source files +# Check src_path directory src_path=/var/www/$app -sudo rm -r $src_path +[[ ! -d $src_path ]] && ynh_die \ +"The destination directory '$DESTDIR' does not exist.\ + The app is not correctly installed, you should remove it first." + +# Move old app dir +sudo mv ${src_path} ${src_path}.old + +# Copy source files sudo mkdir -p $src_path sudo cp -a ../sources/. $src_path -# Retrieve database settings -dbuser=$app -dbname=$app -dbpass=$(yunohost app setting $YNH_APP_INSTANCE_NAME mysqlpwd) +# restore data +sudo cp -a ${src_path}.old/data ${src_path} -# Adding the details of the database to the config file -sed -i "s@__dbuser__@$dbuser@g" ../conf/config.ini.php -sed -i "s@__dbpass__@$dbpass@g" ../conf/config.ini.php -sed -i "s@__dbname__@$dbname@g" ../conf/config.ini.php +# delete temp directory +sudo rm -Rf ${src_path}.old -# Copy the config file to the src_path -sudo cp ../conf/config.ini.php $src_path/data/. # Set permissions to app files # you may need to make some file and/or directory writeable by www-data (nginx user)