aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-06-10 11:47:18 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-06-10 11:47:18 +0200
commit844d35e851b5ef51bc8c0822dbd699b619ddd194 (patch)
tree2d5674a98b39c7731c71351b9ad6cd59ce251d92 /scripts
parentfa1f0a5c44ae059d36fe8e0a384356131f51b9ec (diff)
downloadcalcurse-844d35e851b5ef51bc8c0822dbd699b619ddd194.tar.gz
calcurse-844d35e851b5ef51bc8c0822dbd699b619ddd194.zip
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 <calcurse@cryptocrack.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/calcurse-upgrade.sh.in22
1 files changed, 22 insertions, 0 deletions
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