From 05807e6a47a73a620db920dacd29676807a3c328 Mon Sep 17 00:00:00 2001 From: Jocelyn Delalande Date: Sat, 17 Feb 2018 00:21:07 +0100 Subject: [PATCH] Add rollback function to upgrade --- scripts/upgrade | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 7f0bd8d..98b06ac 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,6 +34,20 @@ fi ynh_app_setting_set "$app" is_public "$is_public" +function exit_properly () { + set +e + # Revert to the old venv + if [ -e /opt/yunohost/ihatemoney/venv-old ] + then + sudo mv /opt/yunohost/ihatemoney/venv{-old,} + fi + # Remove downloaded code + sudo rm -rf ${INSTALL_DIR}/src-new/ + ynh_die "Upgrade script failed, aborted and rolled back the installation" +} +trap exit_properly ERR + + # Upgrade code fetch_and_extract ${INSTALL_DIR}/src-new/ ihatemoney