[Initial]
Message=Installiere MDG Git Client...
DefVar $Version$
DefVar $ExitCode$
DefVar $CreateContextMenuEntry$
DefVar $ContextMenuArguments$

[Aktionen]
ShowBitmap "%ScriptPath%\logo.png" "MDG Git Client"
Sub_GetProperties
Sub_ConfigureProperties
Sub_PrepareInstall
WinBatch_Setup
Sub_HandleExitCode

[Sub_GetProperties]
Set $Version$ = GetValue("productversion", GetProductMap)
Set $CreateContextMenuEntry$ = GetProductProperty("contextmenuentry", "false")

[Sub_ConfigureProperties]
if ($CreateContextMenuEntry$ = "true")
  Set $ContextMenuArguments$ = ",ext,ext\shellhere,ext\guihere"
else
  Set $ContextMenuArguments$ = ""
endif

[Sub_PrepareInstall]
; Kill gpg-agent
if (processIsRunning("gpg-agent.exe"))
  comment "Killing gpg-agent..."
  Killtask "gpg-agent.exe"
  sleepSeconds 3
endif

; Kill ssh-agent
if (processIsRunning("ssh-agent.exe"))
  comment "Killing ssh-agent..."
  Killtask "ssh-agent.exe"
  sleepSeconds 3
endif



[WinBatch_Setup]
%ScriptPath%\data\Git-$Version$-64-bit.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /NOCANCEL /SP- /COMPONENTS="icons,icons\quicklaunch,assoc,assoc_sh,gitlfs$ContextMenuArguments$" /LOG="%opsiLogDir%\git-client-install.log"

; See Components under https://github.com/git-for-windows/build-extra/blob/HEAD/installer/install.iss

[Sub_HandleExitCode]
; check return code
Set $ExitCode$ = GetLastExitCode
comment "GetLastExitCode: " + $ExitCode$
if not($ExitCode$ = "0")
  LogError "Fatal: setup returned exit code " + $ExitCode$
  IsFatalError
endif
