I've modified your script with some enhancements:
1. Let the user choose the firefox flavor (regular or ESR) without editing the script 2. Apply the librewolf patch directly after installing (No 7za) 3. Remove the telemetry that points to firefox.settings.services.mozilla.com (issue #10)
This commit is contained in:
parent
f560babc69
commit
7493fce0e3
1 changed files with 78 additions and 19 deletions
97
package.ps1
97
package.ps1
|
|
@ -1,30 +1,89 @@
|
||||||
# delete old things...
|
Import-Module BitsTransfer
|
||||||
Remove-Item -Path firefox.exe -Force
|
|
||||||
Remove-Item -Path librewolf -Force
|
|
||||||
|
|
||||||
|
$ProgramName = "*Mozilla*Firefox*"
|
||||||
|
$installPath = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.getValue('DisplayName') -like $ProgramName } | ForEach-Object { $_.getValue('InstallLocation')}
|
||||||
|
|
||||||
# windows download version lastest win64
|
if (!$installPath) {
|
||||||
$url = "https://download.mozilla.org/?product=firefox-latest-ssl&os=win64"
|
|
||||||
|
|
||||||
# windows download version lastest win32
|
# Choose firefox flavor
|
||||||
#$url = "https://download.mozilla.org/?product=firefox-latest-ssl&os=win"
|
write-host ""
|
||||||
|
write-host "1 - Download Firefox"
|
||||||
|
write-host "2 - Download Firefox Extended Support Release"
|
||||||
|
write-host ""
|
||||||
|
write-host "E - Exit"
|
||||||
|
write-host ""
|
||||||
|
write-host -nonewline "Type your choice and press Enter: "
|
||||||
|
|
||||||
|
$choice = read-host
|
||||||
|
switch -Regex ( $choice ) {
|
||||||
|
1 { Write-Host "Firefox" -ForegroundColor Green; $url = "https://download.mozilla.org/?product=firefox-latest-ssl&os=win"}
|
||||||
|
2 {Write-Host "Firefox ESR" -ForegroundColor Green; $url = "https://download.mozilla.org/?product=firefox-esr-latest-ssl&os=win"}
|
||||||
|
default { exit }
|
||||||
|
}
|
||||||
|
if ([IntPtr]::size -eq 8) { # Check if the system is 64bit and download the correct version
|
||||||
|
$url += "64"
|
||||||
|
}
|
||||||
|
|
||||||
$downloadfile = "$PSScriptRoot\firefox.exe"
|
$downloadfile = "\FirefoxInstaller.exe"
|
||||||
|
Write-Output "Downloading firefox..."
|
||||||
|
Start-BitsTransfer -Source $url -Destination $downloadfile
|
||||||
|
|
||||||
Write-Output "Downloading to $downloadfile"
|
Write-Output ""
|
||||||
|
Write-Output "Installing Firefox. Please, follow the wizard"
|
||||||
|
Start-Process $downloadfile -NoNewWindow -Wait
|
||||||
|
|
||||||
# download firefox
|
# Check if firefox is running and close/kill
|
||||||
Invoke-WebRequest -Uri $url -outfile $downloadfile
|
while ($firefox = Get-Process firefox -ErrorAction SilentlyContinue) {
|
||||||
|
$firefox.CloseMainWindow()
|
||||||
|
# kill after five seconds
|
||||||
|
Sleep 10
|
||||||
|
if (!$firefox.HasExited) {
|
||||||
|
$firefox | Stop-Process -Force
|
||||||
|
}
|
||||||
|
Sleep 3
|
||||||
|
}
|
||||||
|
|
||||||
Write-Output "Extracting $downloadfile to librewolf"
|
# Check if firefox is installed
|
||||||
# extract with 7zip
|
Remove-Item $downloadfile
|
||||||
& "$PSScriptRoot\7za.exe" x -olibrewolf .\firefox.exe
|
$installPath = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Where-Object { $_.getValue('DisplayName') -like $ProgramName } | ForEach-Object { $_.getValue('InstallLocation')}
|
||||||
|
if (!$installPath) {
|
||||||
|
Write-Output "Firefox can't be located. Process can't continue"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {Write-Host "Firefox is installed" }
|
||||||
|
|
||||||
|
while ($firefox = Get-Process firefox -ErrorAction SilentlyContinue) {
|
||||||
|
$firefox.CloseMainWindow()
|
||||||
|
# kill after five seconds
|
||||||
|
Sleep 5
|
||||||
|
if (!$firefox.HasExited) {
|
||||||
|
$firefox | Stop-Process -Force
|
||||||
|
}
|
||||||
|
Sleep 3
|
||||||
|
}
|
||||||
|
|
||||||
Write-Output "Delete files with privacy....."
|
Write-Output "Delete files with privacy....."
|
||||||
# remove contact with mothership
|
Remove-Item -Path $installPath\crashreporter.exe -Force
|
||||||
Remove-Item -Path librewolf\core\crashreporter.exe -Force
|
Remove-Item -Path $installPath\updater.exe -Force
|
||||||
Remove-Item -Path librewolf\core\updater.exe -Force
|
Remove-Item -Path $installPath\pingsender.exe -Force
|
||||||
Remove-Item -Path librewolf\core\pingsender.exe -Force
|
|
||||||
|
Write-Output "Extra privacy..."
|
||||||
|
$bytes = [System.IO.File]::ReadAllBytes("$installPath\omni.ja")
|
||||||
|
$hexString = [System.BitConverter]::ToString($bytes)
|
||||||
|
$offset = $hexString.IndexOf("3F-20-22-68-74-74-70-73-3A-2F-2F-66-69-72-65-66-6F-78-2E-73-65-74-74-69-6E-67-73-2E-73-65-72-76-69-63-65-73-2E-6D-6F-7A-69-6C-6C-61-2E-63-6F")
|
||||||
|
if ($offset -gt -1) {
|
||||||
|
$offset = $offset/3
|
||||||
|
For ($i=3; $i -le 50; $i++) {
|
||||||
|
$bytes[$offset+$i] = 32
|
||||||
|
}
|
||||||
|
[System.IO.File]::WriteAllBytes("$installPath\omni2.ja", $bytes)
|
||||||
|
Remove-Item -Path $installPath\omni.ja -Force
|
||||||
|
Rename-Item -Path $installPath\omni2.ja omni.ja
|
||||||
|
}
|
||||||
|
|
||||||
Write-Output "Copy librewolf settings"
|
Write-Output "Copy librewolf settings"
|
||||||
Copy-Item -Path "$PSScriptRoot\settings\*" -Destination "$PSScriptRoot\librewolf\core" -Recurse -force
|
$scriptPath = Split-Path -Path $MyInvocation.MyCommand.Path
|
||||||
|
Copy-Item "$scriptPath\settings\*" -Destination "$installPath" -Recurse -Force
|
||||||
|
|
||||||
|
Write-Output "Enjoy"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue