Compare commits
4 Commits
210287ccc5
...
6afe204089
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6afe204089 | ||
![]() |
e1d69cbc15 | ||
![]() |
db51eb23ac | ||
![]() |
c5d8adbe42 |
@ -15,7 +15,7 @@ services:
|
||||
- tor
|
||||
volumes:
|
||||
- bitcoin_data:/home/bitcoin/.bitcoin
|
||||
- ./bitcoin/bitcoin.conf:/home/bitcoin/.bitcoin/bitcoin.conf
|
||||
- ./bitcoin/bitcoin.conf:/etc/bitcoin/bitcoin.conf:ro
|
||||
networks:
|
||||
btcnet:
|
||||
aliases:
|
||||
@ -23,10 +23,10 @@ services:
|
||||
user: root
|
||||
entrypoint: >
|
||||
/bin/sh -c "
|
||||
chown -R bitcoin:bitcoin /home/bitcoin/.bitcoin &&
|
||||
su-exec bitcoin bitcoind -conf=/home/bitcoin/.bitcoin/bitcoin.conf -signet -printtoconsole"
|
||||
chown -R bitcoin:bitcoin /home/bitcoin/.bitcoin || echo 'warn: chown partiel (fichiers bind-mount Windows)';
|
||||
exec su-exec bitcoin bitcoind -conf=/etc/bitcoin/bitcoin.conf -signet -printtoconsole"
|
||||
healthcheck:
|
||||
test: ["CMD", "bitcoin-cli", "-conf=/home/bitcoin/.bitcoin/bitcoin.conf", "getblockchaininfo"]
|
||||
test: ["CMD", "bitcoin-cli", "-conf=/etc/bitcoin/bitcoin.conf", "getblockchaininfo"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
@ -5,15 +5,16 @@
|
||||
!define MUI_ICON "kogusico.ico"
|
||||
!define MUI_UNICON "kogusico.ico"
|
||||
!define MUI_UNINST_ICON "kogusico.ico"
|
||||
!define MUI_UNINSTALLER ; active l’uninstaller
|
||||
!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 l’uninstaller
|
||||
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 l’entré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
|
||||
|
BIN
kogusico.ico
BIN
kogusico.ico
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.5 KiB |
217
run.ps1
217
run.ps1
@ -1,56 +1,189 @@
|
||||
# run.ps1 — script d'installation et de démarrage
|
||||
# run.ps1 — installation & démarrage automatiques (Windows)
|
||||
# - Installe Docker Desktop si absent
|
||||
# - Active WSL2/VirtualMachinePlatform si nécessaire
|
||||
# - Démarre Docker Desktop (headless) et attend le daemon
|
||||
# - Lance `docker compose up -d`
|
||||
# - Enregistre une reprise RunOnce + retourne 3010 si un reboot est requis
|
||||
|
||||
Param()
|
||||
Param(
|
||||
[switch]$PostReboot
|
||||
)
|
||||
|
||||
# 1. Detection de la CLI Docker (docker vs docker-compose)
|
||||
Write-Host "=== Verification de Docker CLI ==="
|
||||
$dockerCmd = $null
|
||||
try {
|
||||
docker version --format '{{.Client.Version}}' > $null 2>&1
|
||||
$dockerCmd = 'docker'
|
||||
} catch {
|
||||
try {
|
||||
docker-compose version > $null 2>&1
|
||||
$dockerCmd = 'docker-compose'
|
||||
} catch {
|
||||
$dockerCmd = $null
|
||||
}
|
||||
# --- Sécurité / contexte ---
|
||||
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
if (-not $IsAdmin) {
|
||||
Write-Host "Relance en administrateur..."
|
||||
Start-Process -Verb RunAs -FilePath "powershell.exe" -ArgumentList "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", "`"$PSCommandPath`""
|
||||
exit
|
||||
}
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
if ($dockerCmd) {
|
||||
Write-Host "Docker CLI detectee : $dockerCmd"
|
||||
} else {
|
||||
Write-Host "Docker non trouve. Installation de Docker Desktop..."
|
||||
$installerUrl = 'https://desktop.docker.com/win/stable/Docker%20Desktop%20Installer.exe'
|
||||
$installerPath = Join-Path -Path $PSScriptRoot -ChildPath 'docker-installer.exe'
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $installerUrl -OutFile $installerPath
|
||||
Start-Process -FilePath $installerPath -ArgumentList '/quiet' -Wait
|
||||
Remove-Item -Path $installerPath -Force
|
||||
Write-Host "Installation de Docker Desktop terminee."
|
||||
$dockerCmd = 'docker'
|
||||
}
|
||||
|
||||
# 2. Se placer dans le repertoire contenant docker-compose.yml
|
||||
Push-Location
|
||||
# --- Dossiers / chemins ---
|
||||
$installRoot = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
|
||||
Set-Location $installRoot
|
||||
|
||||
# 3. Creation du dossier de logs
|
||||
$logDir = Join-Path -Path $installRoot -ChildPath 'logs'
|
||||
if (-not (Test-Path $logDir)) {
|
||||
New-Item -ItemType Directory -Path $logDir | Out-Null
|
||||
if (-not (Test-Path $logDir)) { New-Item -ItemType Directory -Path $logDir | Out-Null }
|
||||
$PsLog = Join-Path $logDir 'install-ps.log' # <— log distinct pour éviter le verrou NSIS
|
||||
|
||||
Push-Location $installRoot
|
||||
|
||||
$ProgramFilesDocker = Join-Path $Env:ProgramFiles 'Docker\Docker'
|
||||
$DockerExe = Join-Path $ProgramFilesDocker 'resources\bin\docker.exe'
|
||||
$DockerDesktopExe = Join-Path $ProgramFilesDocker 'Docker Desktop.exe'
|
||||
$DockerCliExe = Join-Path $ProgramFilesDocker 'DockerCli.exe'
|
||||
|
||||
function Write-Log($msg) {
|
||||
$stamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
|
||||
try { Add-Content -Path $PsLog -Value "$stamp $msg" -Encoding utf8 -ErrorAction SilentlyContinue } catch { }
|
||||
Write-Host $msg
|
||||
}
|
||||
|
||||
# 4. Demarrage de la stack et redirection des logs
|
||||
$composeCmd = if ($dockerCmd -eq 'docker') { 'docker compose' } else { 'docker-compose' }
|
||||
Write-Host "Lancement de '$composeCmd up -d'..."
|
||||
function Test-PendingReboot {
|
||||
$paths = @(
|
||||
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending',
|
||||
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired',
|
||||
'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager'
|
||||
)
|
||||
foreach ($p in $paths) {
|
||||
if (Test-Path $p) {
|
||||
if ($p -like '*Session Manager*') {
|
||||
$val = (Get-ItemProperty -Path $p -Name 'PendingFileRenameOperations' -ErrorAction SilentlyContinue)
|
||||
if ($val) { return $true }
|
||||
}
|
||||
else { return $true }
|
||||
}
|
||||
}
|
||||
return $false
|
||||
}
|
||||
|
||||
function Register-RunOnce {
|
||||
$runOnceKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce'
|
||||
New-Item -Path $runOnceKey -Force | Out-Null
|
||||
$cmd = "powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" -PostReboot"
|
||||
Set-ItemProperty -Path $runOnceKey -Name 'KogusPostInstall' -Value $cmd
|
||||
Write-Log "RunOnce enregistré : $cmd"
|
||||
}
|
||||
|
||||
function Enable-WSLPrereqs {
|
||||
Write-Log "Activation des fonctionnalités Windows (WSL2 / VirtualMachinePlatform) si nécessaire..."
|
||||
$rebootNeeded = $false
|
||||
& dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart | Out-Null
|
||||
if ($LASTEXITCODE -eq 3010) { $rebootNeeded = $true }
|
||||
& dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart | Out-Null
|
||||
if ($LASTEXITCODE -eq 3010) { $rebootNeeded = $true }
|
||||
try { wsl.exe --set-default-version 2 > $null 2>&1 } catch { }
|
||||
return $rebootNeeded
|
||||
}
|
||||
|
||||
function Install-DockerDesktop {
|
||||
if (Test-Path $DockerExe) { return $false }
|
||||
Write-Log "Docker Desktop absent : installation silencieuse…"
|
||||
$installerUrl = 'https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe'
|
||||
$installerPath = Join-Path -Path $installRoot -ChildPath 'docker-installer.exe'
|
||||
try {
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $installerUrl -OutFile $installerPath
|
||||
}
|
||||
catch {
|
||||
Write-Log "Téléchargement direct échoué, tentative via winget…"
|
||||
try {
|
||||
winget --version > $null 2>&1
|
||||
winget install --id Docker.DockerDesktop -e --accept-source-agreements --accept-package-agreements
|
||||
return $true
|
||||
}
|
||||
catch { throw "Impossible de télécharger Docker Desktop ($($_.Exception.Message))." }
|
||||
}
|
||||
$InstallerArguments = @('install', '--quiet', '--accept-license', '--backend=wsl-2', '--always-run-service') # flags officiels
|
||||
Start-Process -FilePath $installerPath -ArgumentList $InstallerArguments -Wait
|
||||
Remove-Item -Path $installerPath -Force -ErrorAction SilentlyContinue
|
||||
Write-Log "Installation de Docker Desktop terminée."
|
||||
return $true
|
||||
}
|
||||
|
||||
function Ensure-UserInDockerUsers {
|
||||
try { & net localgroup docker-users $env:USERNAME /add > $null 2>&1 } catch { }
|
||||
}
|
||||
|
||||
function Start-DockerDesktop-And-Wait {
|
||||
# 1) s'assurer que le service est en auto + démarré
|
||||
try { Set-Service -Name 'com.docker.service' -StartupType Automatic -ErrorAction SilentlyContinue } catch { }
|
||||
try { Start-Service -Name 'com.docker.service' -ErrorAction SilentlyContinue } catch { }
|
||||
|
||||
# 2) démarrage headless via Docker Desktop CLI (4.37+) → docker desktop start/status/engine use
|
||||
try { & $DockerExe desktop start > $null 2>&1 } catch { }
|
||||
try { & $DockerExe desktop engine use linux > $null 2>&1 } catch { } # force le moteur Linux
|
||||
|
||||
# 3) boucle d’attente (statut Desktop + daemon Engine)
|
||||
$deadline = (Get-Date).AddMinutes(10)
|
||||
while ((Get-Date) -lt $deadline) {
|
||||
try {
|
||||
$status = (& $DockerExe desktop status 2>$null).Trim()
|
||||
if ($status -match 'running') {
|
||||
& $DockerExe version --format '{{.Server.Version}}' > $null 2>&1
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Log "Docker Desktop: $status (daemon OK)"
|
||||
return $true
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
Start-Sleep -Seconds 3
|
||||
}
|
||||
|
||||
# 4) fallback : lancer l’UI si nécessaire (premier démarrage/initialisation WSL)
|
||||
try { Start-Process -FilePath $DockerDesktopExe -ErrorAction SilentlyContinue } catch { }
|
||||
$deadline2 = (Get-Date).AddMinutes(10)
|
||||
while ((Get-Date) -lt $deadline2) {
|
||||
try {
|
||||
& $DockerExe version --format '{{.Server.Version}}' > $null 2>&1
|
||||
if ($LASTEXITCODE -eq 0) { Write-Log "Docker daemon prêt (après lancement UI)."; return $true }
|
||||
}
|
||||
catch { }
|
||||
Start-Sleep -Seconds 3
|
||||
}
|
||||
|
||||
Write-Log "Le daemon Docker ne répond pas (timeout)."
|
||||
return $false
|
||||
}
|
||||
|
||||
# --- Orchestration ---
|
||||
$rebootNeeded = $false
|
||||
|
||||
if (-not $PostReboot) {
|
||||
if (Enable-WSLPrereqs) { $rebootNeeded = $true }
|
||||
}
|
||||
|
||||
$installedNow = $false
|
||||
if (-not (Get-Command $DockerExe -ErrorAction SilentlyContinue)) {
|
||||
$installedNow = Install-DockerDesktop
|
||||
}
|
||||
|
||||
if ($rebootNeeded -or (Test-PendingReboot)) {
|
||||
Write-Log "Un redémarrage Windows est requis. Enregistrement d'une reprise automatique…"
|
||||
Register-RunOnce
|
||||
Pop-Location
|
||||
exit 3010
|
||||
}
|
||||
|
||||
Ensure-UserInDockerUsers
|
||||
if (-not (Start-DockerDesktop-And-Wait)) {
|
||||
Write-Log "Docker n'est pas prêt. Un redémarrage peut être requis."
|
||||
Pop-Location
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Lancer la stack
|
||||
$composeCmd = "`"$DockerExe`" compose"
|
||||
Write-Log "Lancement de '$composeCmd up -d'…"
|
||||
$runLog = Join-Path -Path $logDir -ChildPath 'run.log'
|
||||
# On passe par cmd.exe pour que > et 2>&1 fonctionnent correctement
|
||||
& cmd.exe /c "$composeCmd up -d > `"$runLog`" 2>&1"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Erreur lors du demarrage. Voir le log : $runLog"
|
||||
} else {
|
||||
Write-Host "Stack demarree. Logs disponibles dans : $runLog"
|
||||
Write-Log "Erreur lors du démarrage. Voir le log : $runLog"
|
||||
Pop-Location
|
||||
exit 1
|
||||
}
|
||||
else {
|
||||
Write-Log "Stack démarrée. Logs : $runLog"
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
exit 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user