- Lea.iss : script Inno Setup 6 (enrollment 2 pages, licence, machine_id) - build_installer.sh : staging + ISCC (compatible Wine sur Linux) - uninstall_lea.ps1 : kill PID + cleanup + notif serveur - configure_embed.ps1 : Python 3.12 embedded optionnel - config_template.txt : modèle pour installation silencieuse - LICENSE.txt : CGU AI Act Art. 50 - README.md : doc build, signing, déploiement silencieux Paramètres d'installation silencieuse : Lea-Setup-v1.0.0.exe /VERYSILENT /CONFIG=enroll.txt /LOG=install.log Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
100 lines
4.1 KiB
PowerShell
100 lines
4.1 KiB
PowerShell
# ============================================================
|
|
# uninstall_lea.ps1 — Script de desinstallation propre de Lea
|
|
# ------------------------------------------------------------
|
|
#
|
|
# Appele par Inno Setup via [UninstallRun] AVANT la suppression
|
|
# des fichiers. Roles :
|
|
#
|
|
# 1. Tuer proprement le process Lea (via PID du lock)
|
|
# 2. Nettoyer shell:startup (supprimer le raccourci auto-start)
|
|
# 3. Notifier le serveur de la desinstallation (best-effort)
|
|
# 4. Supprimer le lock file
|
|
#
|
|
# Usage (par Inno Setup) :
|
|
# powershell.exe -NoProfile -ExecutionPolicy Bypass \
|
|
# -File uninstall_lea.ps1 -AppDir "C:\Program Files\Lea"
|
|
# ============================================================
|
|
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$AppDir
|
|
)
|
|
|
|
$ErrorActionPreference = 'SilentlyContinue'
|
|
Write-Host "Desinstallation de Lea en cours..."
|
|
|
|
# ---------------------------------------------------------------
|
|
# 1. Tuer le process via PID du lock file
|
|
# ---------------------------------------------------------------
|
|
$LockFile = Join-Path $AppDir "lea_agent.lock"
|
|
if (Test-Path $LockFile) {
|
|
try {
|
|
$Pid = (Get-Content $LockFile -ErrorAction Stop | Select-Object -First 1).Trim()
|
|
if ($Pid -match '^\d+$') {
|
|
Write-Host " Arret du process Lea (PID $Pid)..."
|
|
Stop-Process -Id ([int]$Pid) -Force -ErrorAction SilentlyContinue
|
|
Start-Sleep -Seconds 1
|
|
}
|
|
} catch {
|
|
Write-Host " Lock file illisible (ignore)."
|
|
}
|
|
Remove-Item $LockFile -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# ---------------------------------------------------------------
|
|
# 2. Nettoyer shell:startup (peut ne pas exister si composant
|
|
# non installe, on le supprime silencieusement dans tous les cas)
|
|
# ---------------------------------------------------------------
|
|
$StartupDir = [Environment]::GetFolderPath('Startup')
|
|
$StartupShortcut = Join-Path $StartupDir "Lea.lnk"
|
|
if (Test-Path $StartupShortcut) {
|
|
Write-Host " Suppression du raccourci auto-start..."
|
|
Remove-Item $StartupShortcut -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# ---------------------------------------------------------------
|
|
# 3. Notifier le serveur de la desinstallation (best-effort)
|
|
# ---------------------------------------------------------------
|
|
$ConfigFile = Join-Path $AppDir "config.txt"
|
|
$MachineIdFile = Join-Path $AppDir "machine_id.txt"
|
|
if ((Test-Path $ConfigFile) -and (Test-Path $MachineIdFile)) {
|
|
try {
|
|
$ConfigLines = Get-Content $ConfigFile
|
|
$ServerUrl = ($ConfigLines | Where-Object { $_ -match '^RPA_SERVER_URL=' } | Select-Object -First 1) -replace '^RPA_SERVER_URL=', ''
|
|
$Token = ($ConfigLines | Where-Object { $_ -match '^RPA_API_TOKEN=' } | Select-Object -First 1) -replace '^RPA_API_TOKEN=', ''
|
|
$MachineId = (Get-Content $MachineIdFile -ErrorAction Stop | Select-Object -First 1).Trim()
|
|
|
|
if ($ServerUrl -and $Token -and $MachineId) {
|
|
Write-Host " Notification du serveur..."
|
|
$Body = @{
|
|
machine_id = $MachineId
|
|
hostname = $env:COMPUTERNAME
|
|
event = 'uninstall'
|
|
timestamp = (Get-Date -Format "o")
|
|
} | ConvertTo-Json
|
|
|
|
Invoke-RestMethod `
|
|
-Uri "$ServerUrl/agents/uninstall" `
|
|
-Method POST `
|
|
-Body $Body `
|
|
-ContentType 'application/json' `
|
|
-Headers @{ Authorization = "Bearer $Token" } `
|
|
-TimeoutSec 5 `
|
|
-ErrorAction SilentlyContinue | Out-Null
|
|
}
|
|
} catch {
|
|
# Best-effort : on ignore toute erreur reseau/auth
|
|
Write-Host " Notification serveur echouee (ignore)."
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------
|
|
# 4. Supprimer les fichiers restants verrouilles eventuellement
|
|
# ---------------------------------------------------------------
|
|
Start-Sleep -Seconds 1
|
|
Get-ChildItem -Path $AppDir -Filter "*.pyc" -Recurse -ErrorAction SilentlyContinue |
|
|
Remove-Item -Force -ErrorAction SilentlyContinue
|
|
|
|
Write-Host "Desinstallation : pre-traitement termine."
|
|
exit 0
|