diff --git a/manifest.json b/manifest.json index 72df08b..698ab38 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Offer backup storage to a friend.", "fr": "Offrez un espace de stockage à un⋅e ami⋅e." }, - "version": "1.1.10~ynh3", + "version": "1.1.10~ynh4", "url": "https://borgbackup.readthedocs.io", "license": "BSD-3-Clause", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index af3b210..3ae7714 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -26,7 +26,7 @@ ynh_export () { local ynh_arg="" for var in $@; do - ynh_arg=$(echo $var | awk '{print toupper($0)}') + ynh_arg=$(echo "$var" | awk '{print toupper($0)}') if [ "$var" == "path_url" ]; then ynh_arg="PATH" fi @@ -43,7 +43,7 @@ ynh_save_args () { if [ "$var" == "path_url" ]; then setting_var="path" fi - ynh_app_setting_set $app $setting_var ${!var} + ynh_app_setting_set $app $setting_var "${!var}" done } diff --git a/scripts/upgrade b/scripts/upgrade index 5ab24b3..bb19d2c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,6 +14,7 @@ source /usr/share/yunohost/helpers #================================================= app=$YNH_APP_INSTANCE_NAME +ssh_user=$(ynh_app_setting_get --app=$app --key=ssh_user) #================================================= # CHECK IF AN UPGRADE IS NEEDED @@ -33,8 +34,21 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -# Replace backports with pip -rm -f /etc/apt/sources.list.d/$app-stretch-backports.list -install_borg_with_pip -ynh_secure_remove /etc/yunohost/hooks.d/backup/17-data_home +#================================================= +# 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 + ynh_app_setting_set --app=$app --key=ssh_user --value="$(grep -Po 'no-user-rc \K.*$' /home/$ssh_user/.ssh/authorized_keys)" +fi