@@ -226,6 +226,9 @@ Function check_previous_install
226226 StrCpy $UpgradeInstall "0"
227227 IfFileExists "$DATADIR\@INC_CPACK_ARANGO_DATA_DIR@\SERVER" OldFound
228228 IfFileExists "$DATADIR\@INC_CPACK_ARANGO_DATA_DIR@\ENGINE" OldFound
229+ IfSilent 0 continueNoDirectMatch
230+ IfFileExists "$DATADIR\ENGINE" OldFound
231+ continueNoDi
10BC0
rectMatch:
229232 DetailPrint "This is a fresh install."
230233 return
231234OldFound:
@@ -238,7 +241,16 @@ Function stop_old_service
238241 SimpleSC::StopService '${TRI_SVC_NAME}' 0 30
239242 Call WaitForServiceDown
240243 SimpleSC::RemoveService '${TRI_SVC_NAME}'
244+ Pop $0 ; returns an errorcode (<>0) otherwise success (0)
245+ IntCmp $0 0 Done_stop_old
246+ IntCmp $0 1060 Done_stop_old ; service not there, we don't care.
247+ Push $0
248+ SimpleSC::GetErrorMessage
249+ Pop $0
250+ DetailPrint 'Stopping ArangoDB fails - Reason: $0'
251+ MessageBox MB_OK 'Stopping ArangoDB fails - Reason: $0'
241252 ${EndIf}
253+ Done_stop_old:
242254FunctionEnd
243255
244256
@@ -731,7 +743,7 @@ Function UpgradeExisting
731743 push ${ARANGO_EXIT_ALREADY_RUNNING}
732744 pop $0
733745retryDetectUpgradeNeeded:
734- ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --server.rest-server false --log.foreground-tty false --database.check-version" $0
746+ ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --server.rest-server false --log.foreground-tty false --database.check-version $DATADIR " $0
735747 DetailPrint "done Checking whether an existing database needs upgrade: $0"
736748 ${If} $0 == ${ARANGO_EXIT_ALREADY_RUNNING}
737749 ${OrIf} $0 == ${ARANGO_EXIT_COULD_NOT_LOCK}
@@ -759,7 +771,7 @@ retryDetectUpgradeNeeded:
759771 ${EndIf}
760772 DetailPrint "Attempting to run database upgrade: "
761773 ; Now actually do the upgrade
762- ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --server.rest-server false --log.level error --database.auto-upgrade true" $0
774+ ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --server.rest-server false --log.level error --database.auto-upgrade true $DATADIR " $0
763775 DetailPrint "Done running database upgrade: $0"
764776 ${If} $0 != 0
765777 !insertmacro printExitCode $0 "the Upgrade failed, please do a manual upgrade" ""
@@ -886,6 +898,13 @@ FunctionEnd
886898;Installer Sections
887899
888900Section "-Core installation"
901+ IfSilent 0 continueBaseInstall
902+ ; this would be called inside the UI code:
903+ Call check_previous_install
904+ ${If} $UpgradeInstall == "1"
905+ Call stop_old_service
906+ ${EndIf}
907+ continueBaseInstall:
889908 ;Use the entire tree produced by the INSTALL target. Keep the
890909 ;list of directories here in sync with the RMDir commands below.
891910 SetOutPath "$INSTDIR"
@@ -970,9 +989,6 @@ Section "-Core installation"
970989 CreateDirectory $LOGDIR
971990 ${EndIf}
972991
973- ; non-interactive install only hits us here?
974- Call check_previous_install
975-
976992 CreateDirectory $APPDIR
977993 Call assignFileRights
978994 ${If} $UpgradeInstall == "1"
@@ -1255,6 +1271,7 @@ SectionEnd
12551271; "Program Files" for AllUsers, "My Documents" for JustMe...
12561272
12571273var CMDINSTDIR
1274+ var CMDUPGRADE
12581275
12591276Function .onInit
12601277 ; are we allowed to install admin in first place?
@@ -1292,7 +1309,17 @@ Function .onInit
12921309 ${EndIf}
12931310noInstDir:
12941311
1295- # we only want to manipulate APPDIR here if /APPDIR is really set!
1312+ # $AUTOMATIC_UPDATE would be set later in the UI code (if)
1313+ StrCpy $AUTOMATIC_UPDATE "0"
1314+ ${GetParameters} $R0
1315+ ClearErrors
1316+ ${GetOptions} $R0 "/UPGRADE=" $CMDUPGRADE
1317+ IfErrors noUpgrade 0
1318+ IfSilent 0 noUpgrade
1319+ StrCpy $AUTOMATIC_UPDATE "$CMDUPGRADE"
1320+ noUpgrade:
1321+
1322+ # we only want to manipulate APPDIR here if /APPDIR is really set!
12961323 ${GetParameters} $R0
12971324 ClearErrors
12981325 ${GetOptions} $R0 "/APPDIR=" $CMDINSTDIR
0 commit comments