2018-06-14 02:13:59 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2020-02-27 18:22:07 +01:00
|
|
|
ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user)
|
2018-06-14 02:13:59 +02:00
|
|
|
|
2018-08-31 01:11:12 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK IF AN UPGRADE IS NEEDED
|
|
|
|
#=================================================
|
2021-01-11 00:36:16 +01:00
|
|
|
|
2018-08-31 01:11:12 +02:00
|
|
|
ynh_check_app_version_changed
|
|
|
|
|
2018-06-14 02:13:59 +02:00
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2020-02-27 18:22:07 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
|
|
|
|
if [ -f "/etc/apt/sources.list.d/$app-stretch-backports.list" ]; then
|
|
|
|
rm -f /etc/apt/sources.list.d/$app-stretch-backports.list
|
|
|
|
install_borg_with_pip
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "/etc/yunohost/hooks.d/backup/17-data_home" ]; then
|
|
|
|
ynh_secure_remove /etc/yunohost/hooks.d/backup/17-data_home
|
|
|
|
fi
|
|
|
|
|
|
|
|
if echo "$ssh_user" | grep -v ' '; then
|
2021-04-07 03:52:14 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=public_key --value="$(grep -Po 'no-user-rc \K.*$' /home/$ssh_user/.ssh/authorized_keys)"
|
2020-02-27 18:22:07 +01:00
|
|
|
fi
|
2021-01-11 00:36:16 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading dependencies..."
|
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
install_borg_with_pip
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|