From 7c744aa45a4f9470964725d4180c76f53cc814a0 Mon Sep 17 00:00:00 2001 From: Matthieu Fronton Date: Thu, 16 Aug 2012 09:02:51 +0200 Subject: [PATCH] adding rollback feature of the config files (only if install haven't started yet) --- install_yunohost | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/install_yunohost b/install_yunohost index aced745..7fe6df1 100755 --- a/install_yunohost +++ b/install_yunohost @@ -7,8 +7,10 @@ function bck { cp -r --preserve=all "$FULLPATH" "$DST/$(basename $FULLPATH)" } -function restore { - # TODO +function rst { + [[ ! -d "$LEGACY" ]] && echo >&2 "Rollback failed : Unknown folder $LEGACY" && exit $ERR_FAIL_RESTORE + mv -fv "$LEGACY"/* / + [[ $? -ne 0 ]] && echo >&2 "Rollback failed" && exit $ERR_FAIL_RESTORE } # TODO : test if the script is executed as root @@ -113,8 +115,9 @@ then if [[ $? -ne 0 ]] then # TODO : rollback (restore legacy configuration for hostname, sources.list, ...) - echo "Update Repo Failure" - exit 1 + echo "Update Repo Failure : Rolling back" + rst "$LEGACY" + exit $ERR_FAIL_UPDATE fi echo "======== Install ========"