2021-03-19 19:47:11 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2022-03-24 21:01:11 +01:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
2021-03-19 19:47:11 +01:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
2022-03-27 00:20:46 +01:00
|
|
|
app_id=$(ynh_app_setting_get --app=$app --key=app_id)
|
2021-03-19 19:47:11 +01:00
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
2022-03-24 21:01:11 +01:00
|
|
|
ynh_script_progression --message="Checking version..."
|
2021-03-19 19:47:11 +01:00
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
2022-03-24 21:01:11 +01:00
|
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
2021-03-19 19:47:11 +01:00
|
|
|
|
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
|
|
|
# Restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2022-03-24 21:01:11 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
|
2021-03-19 19:47:11 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2022-03-24 21:01:11 +01:00
|
|
|
ynh_script_progression --message="Upgrading source files..."
|
2021-03-19 19:47:11 +01:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2022-03-24 21:01:11 +01:00
|
|
|
ynh_setup_source --dest_dir="$final_path" --keep="/data"
|
2021-03-19 19:47:11 +01:00
|
|
|
fi
|
|
|
|
|
2022-03-24 21:01:11 +01:00
|
|
|
chmod 750 "$final_path"
|
|
|
|
chmod -R o-rwx "$final_path"
|
|
|
|
chown -R $app_id:www-data "$final_path"
|
2022-03-27 00:20:46 +01:00
|
|
|
|
2021-03-19 19:47:11 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-03-24 21:01:11 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|