Built-in Installer Options Running the Firefox installation in Standard mode selects most defaults and has minimal prompts, while the Custom installation type offers a few additional opt
Trang 2Hacking Installation
and Deployment
This chapter offers several options for customizing and deploying
Firefox to more than one computer Topics covered here include using command-line options, hacking the default setup options, creating custom installers, and hacking existing installers For anyone who truly
wants to replace their default browser with Firefox across multiple
comput-ers, this chapter should help in customizing the installation, as well as
pro-viding a mechanism for future updates
Two factors that help with deploying Firefox are that there are minimal
operating system dependencies and installation is highly customizable
When reviewing this chapter, keep your ultimate goal in mind and see if
any of the techniques covered here will fit that goal This chapter is not a
complete deployment guide, but it will help in integrating to current
sys-tems Each section includes examples and site references to great resources
for customizing and deploying
Built-in Installer Options
Running the Firefox installation in Standard mode selects most defaults
and has minimal prompts, while the Custom installation type offers a few
additional options The Setup Type dialog is available after the Welcome
and License Agreement windows, and choosing Custom allows you to
modify the installation path, components to install, and which shortcut
icons to create While these options are good for single-user installations,
the available command-line options can help in automating this process for
multiple computer installations Additionally, the foundations for extracting
and hacking the installer are covered here
Before beginning, download the latest installer from http://
www.getfirefox.com
˛ Built-in installer options
˛ Installation and profile customiza-tion opcustomiza-tions
˛ Creating a custom installer
chapter
in this chapter
by Mel Reyes
Trang 3Using Command-Line Options
The Firefox installer includes command-line options that can be used from a batch file, a script, Active Directory, Novell ZENworks, WinBatch, or any other custom installation pro-cess Figure 13-1 highlights the available parameters that can be used while in command-line mode or in your script To display this prompt, just run the Firefox installer with the -h
parameter from the command prompt:
FirefoxSetup.exe -h
F IGURE 13-1: Custom setup installation options
The easiest parameters to use for purposes of automating the installation process are the -ms
and -ddparameters The -msparameter specifies that the installer run in silent mode, installing with the default options enabled, thus silently installing or upgrading Firefox on each system without changing existing settings The -ddparameter allows you to specify a custom installation or destination directory for the Firefox files
To use the installer in silent mode, just type the following entry either in your script or at the command prompt:
Trang 4The combination of the silent mode and destination directory parameter are nice for customiz-ing the basic installation process To use these parameters together, just type the followcustomiz-ing:
FirefoxSetup.exe -ms -dd d:\Mozilla\Firefox\
You can substitute d:\Mozilla\Firefox\for the directory you wish to use If the destina-tion path includes spaces, try putting quotes around the path, as follows:
FirefoxSetup.exe -ms -dd “d:\Local Apps\Firefox\”
There is a space between the -dd parameter and the installation path name
When using the -msparameter to run in silent mode, the only dialog that is displayed is the setup-file extraction progress This makes it difficult to alert the user that the installation is in progress Status dialogs should be created and can be customized depending on the installation
or scripting system used to automate the installation process Additionally, running the installer
in silent mode creates all the standard icons, desktop, Start menu, and Quick Launch toolbar; a postinstallation process will be needed to remove these if desired
Extracting the Installer
Like many installers, the Firefox installer executable is really just a wrapper to the actual installer setup files The main installer file contains the actual setup.exe and supporting installer files To begin hacking through the installer, you must first extract the single installer file to gain access to the individual files contained within For Windows-based systems, you can use compression extraction tools such as 7-Zip (http://www.7-zip.org/) or WinRar (http://www.rarlab.com/) to quickly view or extract these files
On Linux-based systems, uncompressing the GZipped installer file gives you access to the installation files
To extract the Firefox compressed tarball using Linux or UNIX-based systems, just issue the following commands in a console window, pressing Enter after each line:
tar -xzvf firefox-1.0.4.installer.tar.gz
cd firefox-installer /firefox-installer
Figure 13-2 shows the contents of the installer using 7-Zip, but similar results are achieved using WinRar on the file
Trang 5F IGURE 13-2: Firefox installer listing using 7-Zip
To extract the installer listing with 7-Zip or WinRar, follow these steps:
1 Open Windows Explorer to the path to which you have downloaded the installer.
2 Select the Extract files, Extract Here, or Extract To option from the right-click context
menu
3 Based on the option selected, follow the appropriate dialog to select the path to
extract to
To open or just view the installer’s contents with 7-Zip choose the Open archive option from the right-click context menu; for WinRar select Open with WinRar from the menu
Command-Line Installer Extraction
To extract the installer file in command-line mode using 7-Zip you can use the following:
7z e -o”setup” “Firefox Setup.exe”
Just substitute the name Firefox Setup.exefor the name of the Firefox installer saved locally, and substitute setupfor the subdirectory or full path where you want the files extracted to In our example, a subdirectory will be created called setupin the current path
Trang 6There is no space between the -o and the directory path for extraction.
To have Windows find the 7z executable, the installation path for 7-Zip needs to be added to the Pathenvironment variable You can also accomplish this on the fly by issuing the follow-ing command in Windows just before runnfollow-ing the 7-Zip extraction command:
set Path=%PATH%;C:\Program Files\7-Zip\;
The path of C:\Program Files\7-Zip\ should reflect the local installation path for 7-Zip
The next section covers the options available in the config.ini file to create a customized install process
Hacking the Configuration INI File
As illustrated in Figure 13-2, one file that is included with the Firefox installer is the configu-ration INI file config.ini This file contains different sections for the installation process and default values associated with each section; this is where customizing the installation process can truly be achieved With the multitude of options available, I want to focus on some of the critical options and detail those; they include the following:
Disabling specific dialogs
Running silently
Changing the installation path INI files have a standard structure that includes a header, or section, and then associated name-value pairs INI files can be edited with any standard text editor Additionally, you can include comments, which in the config.ini are prefixed with a semicolon, as shown in the following:
[General]
; Run Mode values:
; Normal - Shows all dialogs Requires user input
; Auto - Shows some dialogs, but none requiring user input
It will
; automatically install the product using default values
; Silent - Show no dialogs at all It will install product using default
; values
Run Mode=Normal
In this example, the header, or section, is [General], and the variable name is Run Mode
with a value of Normal This format allows for human-readable parameters that can be modi-fied easily to create a custom installation
Trang 7Disable Specific Dialog Windows
To begin customizing, I can review the headers associated with each dialog that can be enabled
or disabled by setting the Show Dialogparameter to either TRUEor FALSE, as shown:
Show Dialog=TRUE
The headers are all prefixed with Dialog, are encapsulated with brackets, and include the following:
Dialog Welcome
Dialog License
Dialog Setup Type
Dialog Select Components
Dialog Select Install Path
Dialog Install Successful
To disable the Welcome screen dialog just change the Show Dialogvalue to FALSE,
as follows:
[Dialog Welcome]
Show Dialog=FALSE
Because the file is over 1,100 lines, the easiest way I have found to edit it is to do a search for the header or value that you are looking for and then modify it accordingly Later in this chap-ter, I show you how to bypass this task by using the Nullsoft installer to automate the update of the INI values
Running in Silent Mode
Disabling each of the installer dialogs is nice but does not have to be done if you want to run the installer in silent mode To have the installer run in true silent mode, with absolutely no dialogs, just change the value of the Run Modein the [General]header to Silent, as shown:
[General]
Run Mode=Silent
After you make this change, the setup.exe will run with no dialogs and will use the default set-tings Choosing a Run Modeof Autodoes show the installation process, but the installation will not end properly, and the last dialog window will not close Additionally, the command-line option -mayields the same result as Run Mode=Auto
For more information on –ma support, visit the following Bugzilla posting: https://
bugzilla.mozilla.org/show_bug.cgi?id=229706
Trang 8Modify the Installation Path
To modify the installation path just update the Pathvalue in the [General]section The default value is shown here:
Path=[PROGRAMFILESDIR]\Mozilla Firefox [PROGRAMFILESDIR]is automatically parsed to reflect your program file’s installation path
The INI file also highlights other system-related destination paths that it will recognize when placed in the Pathvalue These include WINDISK, WINDIR, and WINSYSDIR
The Pathvalue can easily also reflect a direct path, as shown:
Path= D:\Mozilla Firefox
The combination of running the installer in true silent mode and customizing the installation path is a great starting point to automating the installation process
Installation and Profile Customization Options
My initial efforts in creating a customized image included using the zipped file distribution that was available up until the 1.0.2 release With the zipped version no longer available, this section focuses on automating some of the supporting elements for using Firefox These tech-niques include creating a profile, installation extensions, and themes globally; deploying plugins and profile templates; and using other tools
Automated Profile Creation
This code allows you to create a profile, and if no directory is specified, a directory with a ran-dom saltprefix is created This random salt string is used as an attempt to reduce profile name spoofing and tampering, and so on All active profiles are listed in the profiles.ini file, usually located at %UserPath%\Mozilla\Firefox
To automatically create a user profile you can use the -CreateProfilecommand-line option that is available For ease of use, follow these steps:
1 Open a command console window.
2 Change into your current Firefox installation path.
3 Type firefox.exe -CreateProfile MyProfile.
In the preceding example,MyProfileis the name you want to call the profile; this name can-not contain spaces The CreateProfileoption can also accept a directory path, so the com-mand would end up looking something like this:
For Windows:
Trang 9Settings\User Name\Application Data\Mozilla\Firefox\Profiles.
For Linux:
firefox.exe -CreateProfile “MyProfile ~/.mozilla/firefox/”
It is important to note that the two parameters, the profile name and the directory paths, need
to be quoted together, as together they are the single value that is used by the -CreateProfileinstruction when you specify a custom path for the MyProfile directory
For more information on other Mozilla Suite command-line options that may work with Firefox, visit http://www.mozilla.org/docs/command-line-args.html
Adding Global Extensions and Themes
One interesting but somewhat limited set of features that is available is global installations
of extensions and themes These options are available as command-line options after Firefox has been installed, so they are Firefox options and not install file options The -install-global-extensionand -install-global-themecommand-line options allow exten-sions and themes to be installed to the main directory in which Firefox is installed, much like the similar option in the Mozilla Suite On the surface, these look to be ideal for deploying extension and themes, but in my experience a global extension installation might not be worth the hassle
Before I dive into how to best use these, I will just cover the issues I have come across in trying
to implement them What I have found on Windows-based systems is that the extension parameter does not play nice when it comes to the location of the actual extension XPI file After some testing, the only way to get extensions to install was to have the XPI file reside in the same directory as the Firefox.exe or the Firefox installation path This makes deploying a tad annoying because the files have to be copied over the computer, the installation for each executed, and then cleaned up afterward This, coupled with the fact that the Options dialog for globally installed extension is disabled, makes it difficult for users to customize extensions All preference changes for globally installed extensions will have to be entered into the user.js
or prefs.js file in the profile
Installing themes globally, though, was a tad smoother, and I was able to get all my themes to install properly
Installing extensions globally works best on brand-new Firefox installations with a new and clean profile Profiles that already contain the same extension that will be installed globally may encounter issues If the extension is installed in the profile, uninstall it and restart Firefox Additionally, the directory associated to the GUID in the profile’s extension directory needs
to be deleted, as well as any references in the chrome.rdf file located in the profile’s chrome directory
Trang 10To install an extension globally, you should make sure of the following:
You have the extension XPI install file saved locally into the Firefox installation path
The user must have read and write access to the Firefox installation path
All instances of Firefox must be closed
Once these have been satisfied, open a command prompt to the Firefox installation path and issue the following command:
firefox -install-global-extension “local_install.xpi”
If the installation fails, try removing the quotes
Though all of this seems straightforward, I have had several issues with getting extensions to register themselves properly, and I would recommend using the extension installation enhance-ments that are slated for the Firefox 1.1 release
With less of a configuration headache, you can install themes by issuing the following command:
firefox -install-global-theme “D:\Firefox\apollo_fx.jar”
As you can see, having the themes in a different directory works and makes installing themes globally a more viable option
For each extension and theme, Firefox will run and then exit, so on slower computers it will take longer to deploy using this method
Deploying Plugins
We covered finding and fixing plugins in Chapter 11; here I show you how to automate the plugin installation and disclose where some of the required files are located
Adding Macromedia Flash and Shockwave Support
To deploy Flash and Shockwave updates that support Firefox, simply run the latest Macromedia installers, and they will automatically add Firefox plugin support Automating this is a little trickier, especially for the Shockwave installer
To download the Flash installer, just visit the following Macromedia site using Firefox and download the installer:http://www.macromedia.com/go/getflashplayer The reason I specify “using Firefox” is if you go to download the installer using Internet Explorer, the site delivers and installs the ActiveX version of the plugin When you download the Flash installer with Firefox, the Macromedia site provides support for Firefox, Opera, and Internet Explorer