From a1c0d4c4cfab56d4bace40eb67ed9bc0886c92df Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 18 May 2021 03:42:43 +0200 Subject: [PATCH] Update upgrade --- scripts/upgrade | 76 +++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 038fe87..7d4c180 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -108,6 +109,11 @@ ynh_system_user_create --username=$app --home_dir=$final_path # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +# sets extended pattern matching options in the bash shell +shopt -s extglob + +datapath=/home/yunohost.app/$app + if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=3 @@ -120,8 +126,37 @@ then mkdir -p $tmpdir/plugins/Ldap_Login ynh_setup_source --dest_dir="$tmpdir/plugins/Ldap_Login" --source_id=ldap_plugin ynh_setup_source --dest_dir="$tmpdir/plugins" --source_id=log_failed_logins_plugin + + # Install files and set permissions + cp -a $tmpdir/!(upload|_data|galleries) $final_path + + # Backward compatibility: + # If the _data subdirectory wasn't already moved to /home/yunohost.app/$app, + # then move it there + if [ ! -h $final_path/_data ] ; then + mv $final_path/_data $datapath + ln -sd $datapath/_data $final_path/_data + fi + + # Backward compatibility: + # If the galleries subdirectory wasn't already moved to /home/yunohost.app/$app, + # then move it there + if [ ! -h $final_path/galleries ] ; then + mv $final_path/galleries $datapath + ln -sd $datapath/galleries $final_path/galleries + fi + + ynh_secure_remove --file="$tmpdir" fi +chmod 750 "$datapath" +chmod -R o-rwx "$datapath" +chown -R $app:www-data "$datapath" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -147,47 +182,6 @@ ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE -#================================================= -# COPY FILES TO $FINAL_PATH -#================================================= - -# sets extended pattern matching options in the bash shell -shopt -s extglob - -datapath=/home/yunohost.app/$app - -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - # Install files and set permissions - cp -a $tmpdir/!(upload|_data|galleries) $final_path - - # Backward compatibility: - # If the _data subdirectory wasn't already moved to /home/yunohost.app/$app, - # then move it there - if [ ! -h $final_path/_data ] ; then - mv $final_path/_data $datapath - ln -sd $datapath/_data $final_path/_data - fi - - # Backward compatibility: - # If the galleries subdirectory wasn't already moved to /home/yunohost.app/$app, - # then move it there - if [ ! -h $final_path/galleries ] ; then - mv $final_path/galleries $datapath - ln -sd $datapath/galleries $final_path/galleries - fi - - ynh_secure_remove --file="$tmpdir" -fi - -chmod 750 "$datapath" -chmod -R o-rwx "$datapath" -chown -R $app:www-data "$datapath" - -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - #================================================= # UPGRADE APPLICATION WITH CURL #=================================================