diff --git a/README.fr.md b/README.fr.md index 5cf77c8..aabb5f3 100644 --- a/README.fr.md +++ b/README.fr.md @@ -20,7 +20,7 @@ Petite boîte à outils Windows pour installer des packs de logiciels libres ave | Chemin | Rôle | | --- | --- | | 🧭 [`powershell/libres-softwares-install.ps1`](./powershell/libres-softwares-install.ps1) | Installateur interactif pour une liste de logiciels sélectionnés. | -| 🦊 [`powershell/Configure-FirefoxDefaults.ps1`](./powershell/Configure-FirefoxDefaults.ps1) | Définit Firefox ESR comme navigateur par défaut et force l'installation de uBlock Origin pour tous les utilisateurs. | +| 🦊 [`powershell/Install-Firefox.ps1`](./powershell/Install-Firefox.ps1) | Installe Firefox ESR, le définit comme navigateur par défaut et force l'installation de uBlock Origin pour tous les utilisateurs. | | 🧹 [`powershell/Winget-Remove-BuiltInApps.ps1`](./powershell/Winget-Remove-BuiltInApps.ps1) | Suppression de certaines applications Windows intégrées pour l'utilisateur courant avec winget. | | 🚫 [`powershell/Remove-BuiltInApps.ps1`](./powershell/Remove-BuiltInApps.ps1) | Suppression de certaines applications Appx intégrées sans winget avec blocages registre pour les futurs utilisateurs. | | 🚀 [`winget/libre-soft-start-pack.yaml`](./winget/libre-soft-start-pack.yaml) | Pack automatisé de départ : Firefox ESR, 7-Zip et VLC. | @@ -88,13 +88,13 @@ Exemple : winget configure --file .\winget\libre-soft-start-pack.yaml --accept-configuration-agreements ``` -Après l'installation d'un pack qui inclut Firefox ESR, lance le script de configuration Firefox depuis un terminal administrateur : +Pour installer Firefox ESR avec la configuration navigateur par défaut et uBlock Origin en une seule étape, lance : ```powershell -powershell -ExecutionPolicy Bypass -File .\powershell\Configure-FirefoxDefaults.ps1 +powershell -ExecutionPolicy Bypass -File .\powershell\Install-Firefox.ps1 ``` -Le script écrit les policies Firefox, force l'installation de uBlock Origin depuis Mozilla Add-ons, configure les paramètres gérés de uBlock Origin et importe les associations d'applications Windows par défaut pour les futurs utilisateurs. +Le script installe Firefox ESR, écrit les policies Firefox, force l'installation de uBlock Origin depuis Mozilla Add-ons, configure les paramètres gérés de uBlock Origin et importe les associations d'applications Windows par défaut pour les futurs utilisateurs. Documentation détaillée : [configuration Firefox ESR et uBlock Origin](./docs/firefox-ublock.md). diff --git a/README.md b/README.md index 0af94c1..7a3bc44 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Small Windows toolkit to install libre software packs with `winget` and remove s | Path | Purpose | | --- | --- | | 🧭 [`powershell/libres-softwares-install.ps1`](./powershell/libres-softwares-install.ps1) | Interactive installer for a curated list of applications. | -| 🦊 [`powershell/Configure-FirefoxDefaults.ps1`](./powershell/Configure-FirefoxDefaults.ps1) | Sets Firefox ESR as default browser and force-installs uBlock Origin for all users. | +| 🦊 [`powershell/Install-Firefox.ps1`](./powershell/Install-Firefox.ps1) | Installs Firefox ESR, sets it as default browser and force-installs uBlock Origin for all users. | | 🧹 [`powershell/Winget-Remove-BuiltInApps.ps1`](./powershell/Winget-Remove-BuiltInApps.ps1) | Removes selected built-in Windows applications for the current user with winget. | | 🚫 [`powershell/Remove-BuiltInApps.ps1`](./powershell/Remove-BuiltInApps.ps1) | Removes selected built-in Appx applications without winget and writes registry blocks for future users. | | 🚀 [`winget/libre-soft-start-pack.yaml`](./winget/libre-soft-start-pack.yaml) | Automated starter pack: Firefox ESR, 7-Zip and VLC. | @@ -88,13 +88,13 @@ Example: winget configure --file .\winget\libre-soft-start-pack.yaml --accept-configuration-agreements ``` -After installing a pack that includes Firefox ESR, run the Firefox configuration script from an administrator terminal: +To install Firefox ESR with the default browser and uBlock Origin configuration in one step, run: ```powershell -powershell -ExecutionPolicy Bypass -File .\powershell\Configure-FirefoxDefaults.ps1 +powershell -ExecutionPolicy Bypass -File .\powershell\Install-Firefox.ps1 ``` -The script writes Firefox enterprise policies, force-installs uBlock Origin from Mozilla Add-ons, configures managed uBlock Origin defaults and imports Windows default app associations for future users. +The script installs Firefox ESR, writes Firefox enterprise policies, force-installs uBlock Origin from Mozilla Add-ons, configures managed uBlock Origin defaults and imports Windows default app associations for future users. More details: [Firefox ESR and uBlock Origin configuration](./docs/firefox-ublock.md). diff --git a/docs/firefox-ublock.md b/docs/firefox-ublock.md index c1ec04f..325920a 100644 --- a/docs/firefox-ublock.md +++ b/docs/firefox-ublock.md @@ -1,7 +1,7 @@ # Configuration Firefox ESR et uBlock Origin Cette page documente la configuration appliquee par -[`powershell/Configure-FirefoxDefaults.ps1`](../powershell/Configure-FirefoxDefaults.ps1). +[`powershell/Install-Firefox.ps1`](../powershell/Install-Firefox.ps1). Le but est de preparer Firefox ESR pour tous les utilisateurs Windows, y compris les futurs profils : @@ -12,16 +12,16 @@ les futurs profils : ## Execution -Lance le script dans un terminal PowerShell administrateur, apres installation de -Firefox ESR : +Lance le script dans un terminal PowerShell administrateur. Il installe Firefox +ESR puis applique la configuration : ```powershell -powershell -ExecutionPolicy Bypass -File .\powershell\Configure-FirefoxDefaults.ps1 +powershell -ExecutionPolicy Bypass -File .\powershell\Install-Firefox.ps1 ``` Le script est aussi appele automatiquement par [`powershell/libres-softwares-install.ps1`](../powershell/libres-softwares-install.ps1) -quand Firefox ESR est installe via l'installateur interactif. +quand Firefox ESR est selectionne via l'installateur interactif. ## Fichiers et cles crees @@ -195,8 +195,9 @@ dism.exe /Online /Get-DefaultAppAssociations Les associations importees par DISM ciblent les futurs profils Windows. Un profil deja cree peut conserver ses associations existantes. -Firefox doit etre installe avant l'execution du script, sinon les ProgID Firefox -peuvent etre absents. +Le script installe Firefox ESR avec winget avant de lire les ProgID Firefox. Si +winget echoue ou si Firefox ne s'enregistre pas correctement, les associations +par defaut ne peuvent pas etre importees. uBlock Origin est telecharge par Firefox depuis Mozilla Add-ons au demarrage. La machine doit donc avoir acces a `addons.mozilla.org`. diff --git a/powershell/Configure-FirefoxDefaults.ps1 b/powershell/Install-Firefox.ps1 similarity index 83% rename from powershell/Configure-FirefoxDefaults.ps1 rename to powershell/Install-Firefox.ps1 index b4b125a..f70fea7 100644 --- a/powershell/Configure-FirefoxDefaults.ps1 +++ b/powershell/Install-Firefox.ps1 @@ -1,8 +1,9 @@ # Requires running as administrator -# Configures Firefox ESR as the default browser and force-installs uBlock Origin. +# Installs Firefox ESR, configures it as the default browser and force-installs uBlock Origin. [CmdletBinding(SupportsShouldProcess = $true)] param( + [string]$FirefoxPackageId = "Mozilla.Firefox.ESR.fr", [string]$AssociationsPath = "$env:ProgramData\WindowsLibreSoftwareToolkit\FirefoxDefaultAssociations.xml" ) @@ -17,6 +18,38 @@ if (-not $IsAdministrator) { exit 1 } +function Install-FirefoxEsr { + param( + [string]$PackageId + ) + + if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { + Write-Error "winget was not found. Install App Installer or enable winget before running this script." + exit 1 + } + + Write-Host "Installing Firefox ESR with winget: $PackageId" -ForegroundColor Cyan + + if ($PSCmdlet.ShouldProcess($PackageId, "Install Firefox ESR")) { + $Arguments = @( + "install", + "--id", $PackageId, + "--silent", + "--accept-source-agreements", + "--accept-package-agreements" + ) + + $Process = Start-Process -FilePath "winget" -ArgumentList $Arguments -NoNewWindow -Wait -PassThru + + if ($Process.ExitCode -ne 0) { + Write-Error "Firefox ESR installation failed. winget exit code: $($Process.ExitCode)" + exit $Process.ExitCode + } + + Write-Host "Firefox ESR installed or already present." -ForegroundColor Green + } +} + function Get-FirefoxExecutablePath { $CandidatePaths = @() @@ -192,10 +225,12 @@ function Set-FirefoxDefaultAssociations { } } +Install-FirefoxEsr -PackageId $FirefoxPackageId + $FirefoxExe = Get-FirefoxExecutablePath if (-not $FirefoxExe) { - Write-Error "Firefox was not found. Install Firefox ESR first, then run this script again." + Write-Error "Firefox was not found after installation. Check the winget package result and retry." exit 1 } @@ -204,4 +239,4 @@ Set-FirefoxEnterprisePolicies -FirefoxExe $FirefoxExe Set-FirefoxDefaultAssociations -OutputPath $AssociationsPath Write-Host "" -Write-Host "Firefox defaults configured. Restart Windows or sign out before creating/testing new users." -ForegroundColor Green +Write-Host "Firefox ESR installed and configured. Restart Windows or sign out before creating/testing new users." -ForegroundColor Green diff --git a/powershell/libres-softwares-install.ps1 b/powershell/libres-softwares-install.ps1 index d6a773d..b605ba3 100644 --- a/powershell/libres-softwares-install.ps1 +++ b/powershell/libres-softwares-install.ps1 @@ -100,23 +100,21 @@ foreach ($logiciel in $logicielsAInstaller) { Write-Host "ID winget: $($logiciel.ID)" -ForegroundColor Gray try { - # Installation avec winget - $process = Start-Process -FilePath "winget" -ArgumentList "install", "--id", $logiciel.ID, "--silent", "--accept-source-agreements", "--accept-package-agreements" -NoNewWindow -Wait -PassThru - - if ($process.ExitCode -eq 0) { - Write-Host "OK $($logiciel.Nom) installe avec succes" -ForegroundColor Green + if ($logiciel.ID -eq "Mozilla.Firefox.ESR.fr") { + $installationFirefox = Join-Path $PSScriptRoot "Install-Firefox.ps1" - if ($logiciel.ID -eq "Mozilla.Firefox.ESR.fr") { - $configurationFirefox = Join-Path $PSScriptRoot "Configure-FirefoxDefaults.ps1" - - if (Test-Path $configurationFirefox) { - Write-Host "Configuration de Firefox ESR comme navigateur par defaut avec uBlock Origin..." -ForegroundColor Cyan - & $configurationFirefox - } else { - Write-Warning "Script de configuration Firefox introuvable: $configurationFirefox" - } + if (-not (Test-Path $installationFirefox)) { + throw "Script d'installation Firefox introuvable: $installationFirefox" } + $process = Start-Process -FilePath "powershell" -ArgumentList "-ExecutionPolicy", "Bypass", "-File", $installationFirefox -NoNewWindow -Wait -PassThru + } else { + # Installation avec winget + $process = Start-Process -FilePath "winget" -ArgumentList "install", "--id", $logiciel.ID, "--silent", "--accept-source-agreements", "--accept-package-agreements" -NoNewWindow -Wait -PassThru + } + + if ($process.ExitCode -eq 0) { + Write-Host "OK $($logiciel.Nom) installe avec succes" -ForegroundColor Green $reussites++ $resultats += @{Logiciel = $logiciel.Nom; Statut = "Succes"} } else {