first commit
This commit is contained in:
0
deployer-firefox-en-entreprise/.gitkeep
Normal file
0
deployer-firefox-en-entreprise/.gitkeep
Normal file
163
deployer-firefox-en-entreprise/customFirefoxInstaller.ps1
Normal file
163
deployer-firefox-en-entreprise/customFirefoxInstaller.ps1
Normal file
@@ -0,0 +1,163 @@
|
||||
####################################################################################################################################
|
||||
#### Script : customFirefoxInstaller.ps1
|
||||
#### Description : Script permettant d'automatiser la création d'un installeur personnalisé de Firefox (40 et +)
|
||||
#### Source : https://inios.fr/deployer-firefox-en-entreprise
|
||||
#### Auteur : alexandre@inios.fr
|
||||
####################################################################################################################################
|
||||
## Dossier d'origine
|
||||
$DIR_root = "C:\firefox_work";
|
||||
$DIR_installeur = "$DIR_root\installeur";
|
||||
$DIR_custom = "$DIR_root\custom"
|
||||
$DIR_make = "$DIR_root\make";
|
||||
|
||||
$TOOL_7zip = "$DIR_root\7zip\App\7-Zip\7z.exe";
|
||||
|
||||
$FILE_7z = "$DIR_make\app.7z";
|
||||
$FILE_tag = "$DIR_make\app.tag";
|
||||
|
||||
$FILE_exe = "$DIR_make\firefox-custom.exe";
|
||||
|
||||
## Compteur
|
||||
$iterator = 1;
|
||||
|
||||
# Récupérer le répertoire de démarrage du script
|
||||
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
|
||||
####################################################################################################################################
|
||||
## Vérification des pré-requis
|
||||
####################################################################################################################################
|
||||
## Vérification de l'existance des répertoires
|
||||
if (!(Test-Path $DIR_root)) {
|
||||
Write-Host "Le répertoire $DIR_root n'existe pas !";
|
||||
$choice = Read-Host "Appuyer sur une touche pour sortir...";
|
||||
exit;
|
||||
}
|
||||
if (!(Test-Path $DIR_installeur)) {
|
||||
Write-Host "Le répertoire $DIR_installeur n'existe pas !";
|
||||
$choice = Read-Host "Appuyer sur une touche pour sortir...";
|
||||
exit;
|
||||
}
|
||||
if (!(Test-Path $DIR_custom)) {
|
||||
Write-Host "Le répertoire $DIR_custom n'existe pas !";
|
||||
$choice = Read-Host "Appuyer sur une touche pour sortir...";
|
||||
exit;
|
||||
}
|
||||
if (!(Test-Path $DIR_make)) {
|
||||
Write-Host "Le répertoire $DIR_make n'existe pas !";
|
||||
$choice = Read-Host "Appuyer sur une touche pour sortir...";
|
||||
exit;
|
||||
}
|
||||
|
||||
## Vérification de la disponibilité de 7z.exe
|
||||
if (!(Test-Path $TOOL_7zip)) {
|
||||
Write-Host "L'utilitaire $TOOL_7zip n'est pas disponible !";
|
||||
$choice = Read-Host "Appuyer sur une touche pour sortir...";
|
||||
exit;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
## Traitement
|
||||
####################################################################################################################################
|
||||
## Afficher le contenu du répertoire stockant l'installeur
|
||||
# Explication
|
||||
Write-Host "Les dossiers suivant sont situés dans $DIR_installeur, veuillez choisir celui que vous souhaitez utiliser en indiquant le numéro entre crochet.";
|
||||
|
||||
# Récupérer la liste des installeurs
|
||||
[array] $items = Get-ChildItem "$DIR_installeur\" | Where-Object {$_.extension -eq ".exe"} | Sort-Object "LastWriteTime";
|
||||
|
||||
# Afficher la liste des dossiers avec le numéro
|
||||
foreach ($item in $items) {
|
||||
Write-Host "[$iterator] - $item";
|
||||
$iterator++;
|
||||
}
|
||||
# Choisir le dossier
|
||||
$choice = Read-Host "Choisir le numéro du dossier à personnaliser";
|
||||
$choice = $items[$choice-1];
|
||||
$archive = "$DIR_installeur\$choice";
|
||||
$choice = $archive.replace('.exe','');
|
||||
|
||||
## Supprimer le répertoire si il existe déjà
|
||||
if (Test-Path $choice) {
|
||||
Remove-Item -Force -Recurse $choice;
|
||||
}
|
||||
|
||||
## Extraire l'installeur
|
||||
Invoke-Expression "$TOOL_7zip x '$archive' -o'$choice'";
|
||||
|
||||
## Suppression de fonctionnalités embarquées
|
||||
# Firefox Hello
|
||||
$file_path = "$choice\core\browser\features\loop@mozilla.org.xpi";
|
||||
if (!(Test-Path $file_path)) {
|
||||
Write-Host "Firefox Hello n'est pas embarqué dans cette version de Firefox";
|
||||
}
|
||||
else {
|
||||
Remove-Item -Force $file_path;
|
||||
}
|
||||
|
||||
# Pocket
|
||||
$file_path = "$choice\core\browser\features\firefox@getpocket.com.xpi";
|
||||
if (!(Test-Path $file_path)) {
|
||||
Write-Host "Firefox Pocket n'est pas embarqué dans cette version de Firefox";
|
||||
}
|
||||
else {
|
||||
Remove-Item -Force $file_path;
|
||||
}
|
||||
|
||||
## Copie des fichiers de personnalisation
|
||||
# autoconfig.js
|
||||
$file_path = "$DIR_custom\autoconfig.js";
|
||||
if (!(Test-Path $file_path)) {Write-Host "Le fichier autoconfig.js n'existe pas dans $DIR_custom"; $choice = Read-Host "Appuyer sur une touche pour sortir..."; exit;}
|
||||
Copy-Item -Path $file_path -Destination "$choice\core\defaults\pref";
|
||||
|
||||
# custom.cfg
|
||||
$file_path = "$DIR_custom\custom.cfg";
|
||||
if (!(Test-Path $file_path)) {Write-Host "Le fichier custom.cfg n'existe pas dans $DIR_custom"; $choice = Read-Host "Appuyer sur une touche pour sortir..."; exit;}
|
||||
Copy-Item -Path $file_path -Destination "$choice\core";
|
||||
|
||||
# profile (si présent)
|
||||
$file_path = "$DIR_custom\profile";
|
||||
if (Test-Path $file_path) {Copy-Item -Path $file_path -Destination "$choice\core\defaults" -Recurse;}
|
||||
|
||||
# dictionnaires (si présent)
|
||||
$file_path = "$DIR_custom\dictionaries\*";
|
||||
if (Test-Path $file_path) {Copy-Item -Path $file_path -Destination "$choice\core\dictionaries";}
|
||||
|
||||
# extensions (si présent)
|
||||
$file_path = "$DIR_custom\extensions";
|
||||
if (Test-Path $file_path) {Copy-Item -Path $file_path -Destination "$choice\core";}
|
||||
|
||||
## Créer l'archive de base
|
||||
# Entrer dans le dossier à personnaliser
|
||||
Set-Location $choice;
|
||||
|
||||
# SI le fichier personnalisé existe, ALORS le supprimer
|
||||
if (Test-Path $FILE_7z) {
|
||||
Remove-Item $FILE_7z;
|
||||
}
|
||||
|
||||
# Créer le fichier personnalisé
|
||||
cmd /c "$TOOL_7zip a -r -t7z $FILE_7z -mx -m0=BCJ2 -m1=LZMA:d24 -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3";
|
||||
|
||||
## Créer le fichier "app.tag"
|
||||
# SI le fichier n'existe pas, ALORS le créer
|
||||
if (!(Test-Path $FILE_tag)) {
|
||||
Add-Content -Path $FILE_tag -Value ';!@Install@!UTF-8!';
|
||||
Add-Content -Path $FILE_tag -Value 'Title="Mozilla Firefox"';
|
||||
Add-Content -Path $FILE_tag -Value 'RunProgram="setup.exe"';
|
||||
Add-Content -Path $FILE_tag -Value ';!@InstallEnd@!';
|
||||
}
|
||||
|
||||
## Créer l'installeur
|
||||
# SI le fichier personnalisé existe, ALORS le supprimer
|
||||
if (Test-Path $FILE_exe) {
|
||||
Remove-Item $FILE_exe;
|
||||
}
|
||||
|
||||
# Créer le package d'installation
|
||||
cmd /c "copy /B $DIR_make\7zSD.sfx+$DIR_make\app.tag+$DIR_make\app.7z $FILE_exe";
|
||||
|
||||
## Attendre pour sortir
|
||||
Write-Host "L'installeur personnalisé est disponible dans $DIR_make sous le nom firefox-custom.exe";
|
||||
$choice = Read-Host "Appuyer pour terminer...";
|
||||
|
||||
## Retourner sur l'emplacement d'origine
|
||||
Set-Location $scriptPath
|
Reference in New Issue
Block a user