From df85456544b11dd903e72e641200003cfb6e04da Mon Sep 17 00:00:00 2001 From: Philipp Storz Date: Sat, 4 May 2013 21:14:59 +0200 Subject: [PATCH] Better handling of existing config files When existing configuration files are found, in interactive mode the user is asked if the existing config file should be kept and the newly generated file is stored aside as config.new. Also, the user can choose to move the existing file to config.old, and install the new one in the original place. This is what is done in silent installation mode. The default for the uninstaller is now to keep existing config files. In silent mode, the uninstaller will remove existing config files. Fixes #140: Winbareos installer renames old config when updating Signed-off-by: Marco van Wieringen --- platforms/win32/winbareos.nsi | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/platforms/win32/winbareos.nsi b/platforms/win32/winbareos.nsi index a9089824dc5..58f868f8db0 100644 --- a/platforms/win32/winbareos.nsi +++ b/platforms/win32/winbareos.nsi @@ -147,12 +147,24 @@ Page custom displayDirconfSnippet SetShellVarContext all ${If} ${FileExists} "$APPDATA\${PRODUCT_NAME}\${fname}" - IfSilent +2 - MessageBox MB_OK|MB_ICONEXCLAMATION \ - "Existing config file found: $APPDATA\${PRODUCT_NAME}\${fname}$\r$\nmoving to $APPDATA\${PRODUCT_NAME}\${fname}.old" - Rename "$APPDATA\${PRODUCT_NAME}\${fname}" "$APPDATA\${PRODUCT_NAME}\${fname}.old" + MessageBox MB_YESNO|MB_ICONQUESTION \ + "Existing config file found: $APPDATA\${PRODUCT_NAME}\${fname}$\r$\nKeep existing config file?" \ + /SD IDNO IDYES keep IDNO move + move: + Rename "$APPDATA\${PRODUCT_NAME}\${fname}" "$APPDATA\${PRODUCT_NAME}\${fname}.old" + Rename "$PLUGINSDIR\${fname}" "$APPDATA\${PRODUCT_NAME}\${fname}" + MessageBox MB_OK|MB_ICONINFORMATION \ + "Existing config file saved as $APPDATA\${PRODUCT_NAME}\${fname}.old" \ + /SD IDOK + GOTO +3 + keep: + Rename "$PLUGINSDIR\${fname}" "$APPDATA\${PRODUCT_NAME}\${fname}.new" + MessageBox MB_OK|MB_ICONINFORMATION \ + "New config file stored $APPDATA\${PRODUCT_NAME}\${fname}.new" \ + /SD IDOK + ${Else} + Rename "$PLUGINSDIR\${fname}" "$APPDATA\${PRODUCT_NAME}\${fname}" ${EndIf} - Rename "$PLUGINSDIR\${fname}" "$APPDATA\${PRODUCT_NAME}\${fname}" CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Edit ${fname}.lnk" "write.exe" '"$APPDATA\${PRODUCT_NAME}\${fname}"' !macroend @@ -562,6 +574,7 @@ Function .onInit File "/oname=$PLUGINSDIR\sed.exe" "sed.exe" File "/oname=$PLUGINSDIR\libcrypto-8.dll" "libcrypto-8.dll" File "/oname=$PLUGINSDIR\libgcc_s_sjlj-1.dll" "libgcc_s_sjlj-1.dll" +# File /nonfatal "/oname=$PLUGINSDIR\libgcc_s_seh-1.dll" "libgcc_s_seh-1.dll" File "/oname=$PLUGINSDIR\libssl-8.dll" "libssl-8.dll" File "/oname=$PLUGINSDIR\libstdc++-6.dll" "libstdc++-6.dll" File "/oname=$PLUGINSDIR\zlib1.dll" "zlib1.dll" @@ -759,7 +772,7 @@ Section Uninstall # ask if existing config files should be kept IfSilent +2 MessageBox MB_YESNO|MB_ICONQUESTION \ - "Do you want to delete the existing configuration files?" /SD IDYES IDNO ConfDeleteSkip + "Do you want to keep the existing configuration files?" /SD IDYES IDYES ConfDeleteSkip Delete "$APPDATA\${PRODUCT_NAME}\bareos-fd.conf" Delete "$APPDATA\${PRODUCT_NAME}\tray-monitor.conf"