Update installer to reboot

This commit is contained in:
omaroughriss 2025-08-13 17:20:48 +02:00
parent e1d69cbc15
commit 6afe204089

View File

@ -5,15 +5,16 @@
!define MUI_ICON "kogusico.ico"
!define MUI_UNICON "kogusico.ico"
!define MUI_UNINST_ICON "kogusico.ico"
!define MUI_UNINSTALLER ; active luninstaller
!define MUI_UNINSTALLER
!include "MUI2.nsh"
!include "LogicLib.nsh"
;--------------------------------
; Métadonnées produit
;--------------------------------
!define PRODUCT_NAME "Kogus"
!define PRODUCT_VERSION "1.0.0"
!define INSTALL_DIR "$PROGRAMFILES\\${PRODUCT_NAME}"
!define INSTALL_DIR "$PROGRAMFILES\${PRODUCT_NAME}"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
!define MUI_PRODUCT "${PRODUCT_NAME}"
@ -37,6 +38,8 @@ InstallDir "${INSTALL_DIR}"
RequestExecutionLevel admin
ShowInstDetails show
Var ExecCode
;--------------------------------
; Section : Installation
;--------------------------------
@ -52,46 +55,53 @@ Section "Install"
File "run.ps1"
; 3. Copier relay
CreateDirectory "$INSTDIR\\relay"
SetOutPath "$INSTDIR\\relay"
File /r "relay\\*.*"
CreateDirectory "$INSTDIR\relay"
SetOutPath "$INSTDIR\relay"
File /r "relay\*.*"
; 4. Copier bitcoin
CreateDirectory "$INSTDIR\\bitcoin"
SetOutPath "$INSTDIR\\bitcoin"
File /r "bitcoin\\*.*"
CreateDirectory "$INSTDIR\bitcoin"
SetOutPath "$INSTDIR\bitcoin"
File /r "bitcoin\*.*"
; 5. Copier blindbit
CreateDirectory "$INSTDIR\\blindbit"
SetOutPath "$INSTDIR\\blindbit"
File /r "blindbit\\*.*"
CreateDirectory "$INSTDIR\blindbit"
SetOutPath "$INSTDIR\blindbit"
File /r "blindbit\*.*"
; 6. Créer dossier de logs
CreateDirectory "$INSTDIR\\logs"
CreateDirectory "$INSTDIR\logs"
; 7. Raccourci Menu Démarrer pour lancer run.ps1
CreateDirectory "$SMPROGRAMS\\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\\${PRODUCT_NAME}\\Lancer Kogus.lnk" \
"$INSTDIR\\run.ps1" "" \
"$INSTDIR\\kogusico.ico" 0
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Lancer Kogus.lnk" \
"$INSTDIR\run.ps1" "" \
"$INSTDIR\kogusico.ico" 0
; 8. Lancement initial (install Docker si besoin)
ExecWait '"$SYSDIR\\WindowsPowerShell\\v1.0\\powershell.exe" -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File "$INSTDIR\\run.ps1" > "$INSTDIR\\logs\\install.log" 2>&1'
; 8. Lancement initial (installe/configure Docker si besoin) + capture code retour
ExecWait '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File "$INSTDIR\run.ps1"' $ExecCode
; 8bis. Si le script signale 3010 => reboot requis (WSL2/VM Platform, etc.)
${If} $ExecCode = 3010
MessageBox MB_ICONQUESTION|MB_YESNO "Un redémarrage est requis pour terminer l'installation de Kogus. Redémarrer maintenant ?" IDYES +2 IDNO +4
SetRebootFlag true
Reboot
${EndIf}
; 9. Auto-démarrage Docker Desktop au login utilisateur
WriteRegStr HKCU "Software\\Microsoft\\Windows\\CurrentVersion\\Run" \
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" \
"DockerDesktop" \
'"$PROGRAMFILES\\Docker\\Docker\\Docker Desktop.exe" --autostart'
'"$PROGRAMFILES\Docker\Docker\Docker Desktop.exe" --autostart'
; 10. Raccourci dans le dossier Démarrage pour relancer la stack Kogus
CreateDirectory "$SMSTARTUP"
CreateShortCut "$SMSTARTUP\\Relancer Kogus Stack.lnk" \
"$SYSDIR\\WindowsPowerShell\\v1.0\\powershell.exe" \
'-NoProfile -ExecutionPolicy Bypass -File "$INSTDIR\\run.ps1"' \
"$INSTDIR\\kogusico.ico" 0
CreateShortCut "$SMSTARTUP\Relancer Kogus Stack.lnk" \
"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" \
'-NoProfile -ExecutionPolicy Bypass -File "$INSTDIR\run.ps1"' \
"$INSTDIR\kogusico.ico" 0
; 11. Générer luninstaller
WriteUninstaller "$INSTDIR\\Uninstall.exe"
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
@ -101,17 +111,17 @@ SectionEnd
Section "Uninstall"
; Arrêter la stack Docker
nsExec::ExecToLog '"$SYSDIR\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -Command "docker compose -f `"$INSTDIR\\docker-compose.yml`" down"'
nsExec::ExecToLog '"$SYSDIR\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -Command "docker compose -f `"$INSTDIR\docker-compose.yml`" down"'
; Supprimer tous les fichiers et dossiers
RMDir /r "$INSTDIR"
; Supprimer le raccourci Menu Démarrer
Delete "$SMPROGRAMS\\${PRODUCT_NAME}\\Lancer Kogus.lnk"
RMDir "$SMPROGRAMS\\${PRODUCT_NAME}"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Lancer Kogus.lnk"
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
; Supprimer le raccourci de démarrage et lentrée registre
Delete "$SMSTARTUP\\Relancer Kogus Stack.lnk"
DeleteRegValue HKCU "Software\\Microsoft\\Windows\\CurrentVersion\\Run" "DockerDesktop"
Delete "$SMSTARTUP\Relancer Kogus Stack.lnk"
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "DockerDesktop"
SectionEnd