From 844d35e851b5ef51bc8c0822dbd699b619ddd194 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 10 Jun 2012 11:47:18 +0200 Subject: calcurse-upgrade: Create a backup before upgrading Make sure the user doesn't end up in a configuration file being totally broken if the upgrade script fails unexpectedly. The backup file is removed if the conversion completed successfully. Signed-off-by: Lukas Fleischer --- scripts/calcurse-upgrade.sh.in | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'scripts/calcurse-upgrade.sh.in') diff --git a/scripts/calcurse-upgrade.sh.in b/scripts/calcurse-upgrade.sh.in index 959cd70..295f736 100644 --- a/scripts/calcurse-upgrade.sh.in +++ b/scripts/calcurse-upgrade.sh.in @@ -40,6 +40,23 @@ if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \ echo "$(gettext "Pre-3.0.0 configuration file format detected...")" + echo -n "$(gettext "Create temporary backup of the configuration file...")" + + backupfile="$CONFFILE.calcurse-upgrade.old" + if [ -e "$backupfile" ]; then + echo + echo "$(gettext "Old backup file found:") \"$backupfile\"" >&2 + echo "$(gettext " +If a previous conversion did not complete, please try to restore your +configuration from this backup and then remove the backup file.")" >&2 + exit 1 + fi + + cp "$CONFFILE" "$backupfile" + + echo -n ' ' + echo "$(gettext 'done')" + tmpfile="$CONFFILE.calcurse-upgrade.tmp" if [ -e "$tmpfile" ]; then echo "$(gettext "Old temporary file found:") \"$tmpfile\"" >&2 @@ -181,5 +198,10 @@ start over with a backup of your old configuration file.")" >&2 echo -n ' ' echo "$(gettext 'done')" + + echo -n "$(gettext "Remove temporary backup...")" + rm "$backupfile" + echo -n ' ' + echo "$(gettext 'done')" fi -- cgit v1.2.3