Merge Firefox install and configuration
This commit is contained in:
@@ -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
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user