1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garradin_ynh.git synced 2024-09-03 18:36:17 +02:00

simplify conditions if pre-upgrade needed

This commit is contained in:
Robles Rodolphe 2021-11-01 19:14:10 +01:00
parent 54dd180713
commit b48900b3f4

View file

@ -25,13 +25,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
if ynh_compare_current_package_version --comparison lt --version 0.9.8.1~ynh1; then upgrade_type=$(ynh_check_app_version_changed)
upgrade_type="0.9.8"
elif ynh_compare_current_package_version --comparison le --version 1.0.7~ynh2; then
upgrade_type="1.1.0"
else
upgrade_type=$(ynh_check_app_version_changed)
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@ -85,7 +79,7 @@ fi
# UPGRADE TO 0.9.8 if necessary # UPGRADE TO 0.9.8 if necessary
#================================================= #=================================================
if [ "$upgrade_type" == "0.9.8" ] if ynh_compare_current_package_version --comparison lt --version 0.9.8.1~ynh1
then then
ynh_script_progression --message="Upgrading upgrade to 0.9.8" --weight=5 ynh_script_progression --message="Upgrading upgrade to 0.9.8" --weight=5
@ -101,13 +95,11 @@ then
backup_bdd=/tmp/association.sqlite backup_bdd=/tmp/association.sqlite
backup_squelettes=/tmp/squelettes backup_squelettes=/tmp/squelettes
if [ -d "$backup_squelettes" ] if [ -d "$backup_squelettes" ]; then
then
cp -ar $backup_squelettes $final_path/www/squelettes cp -ar $backup_squelettes $final_path/www/squelettes
fi fi
if [ -e "$backup_bdd" ] if [ -e "$backup_bdd" ]; then
then
cp -a $backup_bdd $final_path/association.sqlite cp -a $backup_bdd $final_path/association.sqlite
fi fi
@ -135,11 +127,11 @@ fi
# UPGRADE TO 1.1.0 if necessary # UPGRADE TO 1.1.0 if necessary
#================================================= #=================================================
if [ "$upgrade_type" == "1.1.0" ] if ynh_compare_current_package_version --comparison lt --version 1.1.0~ynh1
then then
ynh_script_progression --message="Upgrading upgrade to 1.1.0" --weight=5 ynh_script_progression --message="Upgrading upgrade to 1.1.0" --weight=5
# Download, check integrity, uncompress and patch the source from 1.1.0.src # Download, check integrity, uncompress and patch the source from 0.9.8.src
ynh_setup_source --keep="config.local.php" --dest_dir="$final_path" --source_id="1.1.0" ynh_setup_source --keep="config.local.php" --dest_dir="$final_path" --source_id="1.1.0"
# Set permissions on app files # Set permissions on app files
ynh_system_user_create --username=$app ynh_system_user_create --username=$app
@ -151,13 +143,11 @@ then
backup_bdd=/tmp/association.sqlite backup_bdd=/tmp/association.sqlite
backup_squelettes=/tmp/squelettes backup_squelettes=/tmp/squelettes
if [ -d "$backup_squelettes" ] if [ -d "$backup_squelettes" ]; then
then
cp -ar $backup_squelettes $final_path/www/squelettes cp -ar $backup_squelettes $final_path/www/squelettes
fi fi
if [ -e "$backup_bdd" ] if [ -e "$backup_bdd" ]; then
then
cp -a $backup_bdd $final_path/association.sqlite cp -a $backup_bdd $final_path/association.sqlite
fi fi
@ -225,14 +215,12 @@ ynh_script_progression --message="restore data..." --weight=10
backup_bdd=/tmp/association.sqlite backup_bdd=/tmp/association.sqlite
backup_squelettes=/tmp/squelettes backup_squelettes=/tmp/squelettes
if [ -d "$backup_squelettes" ] if [ -d "$backup_squelettes" ]; then
then
cp -ar $backup_squelettes $final_path/www/squelettes cp -ar $backup_squelettes $final_path/www/squelettes
ynh_secure_remove $backup_squelettes ynh_secure_remove $backup_squelettes
fi fi
if [ -e "$backup_bdd" ] if [ -e "$backup_bdd" ]; then
then
cp -a $backup_bdd $final_path/association.sqlite cp -a $backup_bdd $final_path/association.sqlite
ynh_secure_remove $backup_bdd ynh_secure_remove $backup_bdd
fi fi
@ -270,4 +258,4 @@ chmod 440 "$final_path/config.local.php"
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of Garradin completed" --last ynh_script_progression --message="Upgrade of Garradin completed" --last