Problem with Firefox configuration

Antworten
it_usd_goe
Beiträge: 15
Registriert: 17 Okt 2013, 13:40

Problem with Firefox configuration

Beitrag von it_usd_goe »

Hello everyone.
I would like to deploy Firefox (esr) via Opsi.
The problem is that I have to disable the IPv6 option and I would like to deploy a proxy-setting.
I can only deploy the proxy setting after firefox has been started once, because the file where these settings are configured are created at the first start of firefox.
So I wanted to start firefox after my installation and end the firefox process and execute the CMD file that sets IPv6 and the proxy.
I'm able to start Firefox right after the installation but the process won't close and can't be terminated. Is there anyone who could help me with that issue?

setup.ins:

Code: Alles auswählen

; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
 
[Actions]
requiredWinstVersion >= "4.10.8.6"
 
DefVar $MsiId32$
DefVar $UninstallProgram32$
DefVar $MsiId64$
DefVar $UninstallProgram64$
DefVar $LogDir$
DefVar $ProductCat$ 
DefVar $ProductId$  
DefVar $ProductVersion$
DefVar $AllUsersDesktopLink$
DefVar $AllUsersStartMenuDir$
DefVar $MinimumSpace$
DefVar $InstallDir32$
DefVar $InstallDir64$
DefVar $ExitCode$
DefVar $LicenseRequired$
DefVar $LicenseKey$
DefVar $LicensePool$
DefVar $INST_SystemType$
DefVar $INST_architecture$
 
Set $INST_SystemType$ = GetSystemType
set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
 
 
Set $LogDir$ = "%SystemDrive%\tmp"
 
; ----------------------------------------------------------------
; - Please edit the following values                             -
; ----------------------------------------------------------------
;$ProductId$ should be the name of the product in opsi
; therefore please: only lower letters, no umlauts, 
; no white space use '-' as a seperator
Set $ProductCat$      = "Internet"
Set $ProductId$       = "Firefox"
Set $ProductVersion$  = "24.0"
Set $AllUsersDesktopLink$ = "Mozilla Firefox"
Set $AllUsersStartMenuDir$ = "Mozilla Firefox"
Set $MinimumSpace$    = "200 MB"
; the path were we find the product after the installation
Set $InstallDir32$      = "%ProgramFiles32Dir%\Mozilla Firefox"
Set $InstallDir64$      = "%ProgramFiles32Dir%\Mozilla Firefox"
Set $LicenseRequired$ = "false"
Set $LicensePool$     = "p_" + $ProductId$
; ----------------------------------------------------------------
 
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
	LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
	isFatalError
	; Stop process and set installation status to failed
else
	comment "Show product picture"
	ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$ + " " + $ProductVersion$
 
	if FileExists("%ScriptPath%\delsub.ins")
		comment "Start uninstall sub section"
		Sub "%ScriptPath%\delsub.ins"
	endif
 
	if $LicenseRequired$ = "true"
		comment "Licensing required, reserve license and get license key"
		Sub_get_licensekey
	endif
 
	comment "installing"
 
	if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
		Message "Installing " + $ProductId$ + " 32 Bit..."
		comment "Start setup program"
		Winbatch_install_32
		Sub_check_exitcode
		comment "Copy files"
		Files_install_32 /32Bit
		comment "Patch Registry"
		Registry_install /32Bit
		comment "Create shortcuts"
		LinkFolder_install
	endif
 
	if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
		Message "Installing " + $ProductId$ + " 64 Bit..."
		comment "Start setup program"
		Winbatch_install_64
		Sub_check_exitcode
		comment "Copy files"
		Files_install_64 /64Bit
		comment "Patch Registry"
		Registry_install /64Bit
		comment "Create shortcuts"
		LinkFolder_install
	endif
 
endif
 
[Winbatch_install_32]
 
"%ScriptPath%\files\Firefox$ProductVersion$esr.exe" -ms -ira
"$InstallDir32$\firefox.exe"
killtask "firefox.exe"
"c:\windows\system32\cmd.exe" /c "%ScriptPath%\files\firefox.cmd"

;"%ScriptPath%\files\menu.cmd" "$ProductCat$" "$ProductId$" "$ProductVersion$" "$AllUsersDesktopLink$" "$AllUsersStartMenuDir$"
 
; Choose one of the following examples as basis for your installation
; You can use $LicenseKey$ var to pass a license key to the installer
;
; === Nullsoft Scriptable Install System ================================================================
; "%ScriptPath%\Setup.exe" /S
;
; === MSI package =======================================================================================
; You may use the parameter PIDKEY=$Licensekey$
; msiexec /i "%ScriptPath%\some.msi" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=2 REBOOT=ReallySuppress
;
; === InstallShield + MSI=====================================================================================
; Attention: The path to the log file should not contain any whitespaces
; "%ScriptPath%\setup.exe" /s /v" /l* $LogDir$\$ProductId$.install_log.txt /qb! ALLUSERS=2 REBOOT=ReallySuppress"
; "%ScriptPath%\setup.exe" /s /v" /qb! ALLUSERS=2 REBOOT=ReallySuppress"
;
; === InstallShield =====================================================================================
; Create setup.iss answer file by running: setup.exe /r /f1"c:\setup.iss"
; "%ScriptPath%\setup.exe" /s /sms /f1"%ScriptPath%\setup.iss" /f2"$LogDir$\$ProductId$.install_log.txt"
;
; === Inno Setup ========================================================================================
; http://unattended.sourceforge.net/InnoSetup_Switches_ExitCodes.html
; You may create setup answer file by: setup.exe /SAVEINF="filename"
; You may use an answer file by the parameter /LOADINF="filename"
; "%ScriptPath%\setup.exe" /sp- /silent /norestart
 
 
[Files_install_32]
; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir32$"
copy "%CommonDesktopDir%\$AllUsersDesktopLink$.lnk" "%CommonStartmenuDir%\Programme\$ProductCat$"
copy "%CommonStartmenuDir%\Programme\$AllUsersStartMenuDir$\$AllUsersDesktopLink$.lnk" "%CommonStartmenuDir%\Programme\$ProductCat$"
 
[Winbatch_install_64]
 
"%ScriptPath%\files\Firefox$ProductVersion$esr.exe" -ms -ira
"$InstallDir64$\firefox.exe"
killtask "firefox.exe"
"c:\windows\system32\cmd.exe" /c "%ScriptPath%\files\firefox.cmd"
;"%ScriptPath%\files\menu.cmd" "$ProductCat$" "$ProductId$" "$ProductVersion$" "$AllUsersDesktopLink$" "$AllUsersStartMenuDir$"
 
; Choose one of the following examples as basis for your installation
; You can use $LicenseKey$ var to pass a license key to the installer
;
; === Nullsoft Scriptable Install System ================================================================
; "%ScriptPath%\Setup.exe" /S
;
; === MSI package =======================================================================================
; You may use the parameter PIDKEY=$Licensekey$
; msiexec /i "%ScriptPath%\some.msi" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=2 REBOOT=ReallySuppress
;
; === InstallShield + MSI=====================================================================================
; Attention: The path to the log file should not contain any whitespaces
; "%ScriptPath%\setup.exe" /s /v" /l* $LogDir$\$ProductId$.install_log.txt /qb! ALLUSERS=2 REBOOT=ReallySuppress"
; "%ScriptPath%\setup.exe" /s /v" /qb! ALLUSERS=2 REBOOT=ReallySuppress"
;
; === InstallShield =====================================================================================
; Create setup.iss answer file by running: setup.exe /r /f1"c:\setup.iss"
; "%ScriptPath%\setup.exe" /s /sms /f1"%ScriptPath%\setup.iss" /f2"$LogDir$\$ProductId$.install_log.txt"
;
; === Inno Setup ========================================================================================
; http://unattended.sourceforge.net/InnoSetup_Switches_ExitCodes.html
; You may create setup answer file by: setup.exe /SAVEINF="filename"
; You may use an answer file by the parameter /LOADINF="filename"
; "%ScriptPath%\setup.exe" /sp- /silent /norestart
 
[Files_install_64]
; Example of recursively copying some files into the installation directory:
;
; copy -s "%ScriptPath%\files\*.*" "$InstallDir64$"
copy "%CommonDesktopDir%\$AllUsersDesktopLink$.lnk" "%CommonStartmenuDir%\Programme\$ProductCat$"
copy "%CommonStartmenuDir%\Programme\$AllUsersStartMenuDir$\$AllUsersDesktopLink$.lnk" "%CommonStartmenuDir%\Programme\$ProductCat$"
 
[Registry_install]
; Example of setting some values of an registry key:
;
; openkey [HKEY_LOCAL_MACHINE\Software\$ProductId$]
; set "name1" = "some string value"
; set "name2" = REG_DWORD:0001
; set "name3" = REG_BINARY:00 af 99 cd
 
[LinkFolder_install]
; Example of deleting a folder from AllUsers startmenu:
;
; set_basefolder common_programs
; delete_subfolder $ProductId$
;
; Example of creating an shortcut to the installed exe in AllUsers startmenu:
;
; set_basefolder common_programs
; set_subfolder $ProductId$
;
; set_link
; 	name: $ProductId$
; 	target: <path to the program>
; 	parameters:
; 	working_dir: $InstallDir$
; 	icon_file:
; 	icon_index:
; end_link
;
; Example of creating an shortcut to the installed exe on AllUsers desktop:
;
; set_basefolder common_desktopdirectory
; set_subfolder ""
;
; set_link
; 	name: $ProductId$
; 	target: <path to the program>
; 	parameters: <some_param>
; 	working_dir: $InstallDir$
; 	icon_file: <path to icon file>
; 	icon_index: 2
; end_link
 
 set_basefolder common_programs
 delete_subfolder "$AllUsersStartMenuDir$"
 
 set_basefolder common_programs
 set_subfolder ""
 delete_element "$AllUsersDesktopLink$"
 
 set_basefolder common_desktopdirectory
  set_subfolder ""
 delete_element "$AllUsersDesktopLink$"
 
 
; set_basefolder common_programs
; set_subfolder "$ProductCat$"
 
; set_link
; 	name: $AllUsersDesktopLink$
; 	target: "$InstallDir32$\$ProductId$.exe"
;	working_dir: "$InstallDir32$"
; 	icon_file: "$InstallDir32$\$ProductId$.exe"
; 	icon_index: 0
; end_link
 
 
[Sub_get_licensekey]
comment "License management is enabled and will be used"
 
comment "Trying to get a license key"
Set $LicenseKey$ = demandLicenseKey ($LicensePool$)
; If there is an assignment of exactly one licensepool to the product the following call is possible:
; Set $LicenseKey$ = demandLicenseKey ("", $ProductId$)
;
; If there is an assignment of a license pool to a windows software id, it is possible to use:
; DefVar $WindowsSoftwareId$
; $WindowsSoftwareId$ = "..."
; Set $LicenseKey$ = demandLicenseKey ("", "", $WindowsSoftwareId$)
 
DefVar $ServiceErrorClass$
set $ServiceErrorClass$ = getLastServiceErrorClass
comment "Error class: " + $ServiceErrorClass$
 
if $ServiceErrorClass$ = "None"
	comment "Everything fine, we got the license key '" + $LicenseKey$ + "'"
else
	if $ServiceErrorClass$ = "LicenseConfigurationError"
		LogError "Fatal: license configuration must be corrected"
		LogError getLastServiceErrorMessage
		isFatalError
	else 
		if $ServiceErrorClass$ = "LicenseMissingError"
			LogError "Fatal: required license is not supplied"
			isFatalError
		endif
	endif
endif
 
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
	comment "Looks good: setup program gives exitcode zero"
else
	comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
	if ($ExitCode$ = "1605")
		comment "ERROR_UNKNOWN_PRODUCT	1605	This action is only valid for products that are currently installed."
		comment "Uninstall of a not installed product failed - no problem"
	else
		if ($ExitCode$ = "1641")
			comment "looks good: setup program gives exitcode 1641"
			comment "ERROR_SUCCESS_REBOOT_INITIATED	1641	The installer has initiated a restart. This message is indicative of a success."
		else
			if ($ExitCode$ = "3010")
				comment "looks good: setup program gives exitcode 3010"
				comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	A restart is required to complete the install. This message is indicative of a success."
			else
				logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
				isFatalError
			endif
		endif
	endif
endif
Kind regards
ritsovih
Beiträge: 38
Registriert: 20 Mär 2013, 09:25

Re: Problem with Firefox configuration

Beitrag von ritsovih »

I'm pretty sure that you don't need to do it like you are doing it now.

you can use a prefs.js file which contains your settings and copy that to c:\program files\mozilla Firefox\browser\defaults\profile after installing firefox. all new firefox profiles will contain those settings. already present profiles will not!

Code: Alles auswählen

user_pref("browser.startup.homepage", "https://google.com|https://example.com"); //set both google and example as homepages
user_pref("network.proxy.type", 5); //use system (i.e. Internet Explorer) proxy settings

user_pref("app.update.auto", true);
user_pref("app.update.autoUpdateEnabled", true);
user_pref("app.update.enabled", true);

user_pref("dom.disable_open_during_load", false); //globally disable popup blocker
if you want to push the same settings to all users, whether they have a firefox profile or not, you should use a loginscript or something to overwrite/modify the prefs.js file in %appdata%Mozilla\Firefox\Profiles\<some-random-guid>.default

an alternative to prefs.js is to use mozilla.cfg, which you must copy to c:\program files\Mozilla firefox\

in addition to that you also need to copy a file called local-settings.js to c:\Program Files\Mozilla Firefox\defaults\pref which contains the following:

Code: Alles auswählen

 pref("general.config.obscure_value", 0); // only needed if you do not want to obscure the content with ROT-13
 pref("general.config.filename", "mozilla.cfg");

example mozilla.cfg

Code: Alles auswählen

//Sets the proxy to use the system proxy settings (0, for no proxy)
lockPref("network.proxy.type", 5);

//disables automatic and manual updating
lockPref("app.update.auto", false);
lockPref("app.update.enabled", false);

//disables Maintenance service
lockPref("app.update.service.enabled", false);

//lockPref("browser.rights.override", true);

//disable stupid firefox startpage
lockPref("browser.startup.homepage_override.mstone", "ignore")

pref("browser.startup.homepage", "https://google.com|https://example.com");

pref("capability.policy.policynames", "localfilelinks");
pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");

user_pref("dom.disable_open_during_load", false); //globally disable popup blocker

//below lines to suppress warnings when also deploying extra extensions
pref("extensions.autoDisableScopes", 0);
pref("extensions.enabledScopes", 15);
I can't remember for sure but I think the mozilla.cfg also only applies to newly created firefox profiles

if you still want to go the original route, I'd add something like below to your batch file, instead of the two opsi commands to open and kill firefox.

Code: Alles auswählen

start "c:\program files\Mozilla firefox\firefox.exe"
taskkill /F /IM "firefox.exe"
it_usd_goe
Beiträge: 15
Registriert: 17 Okt 2013, 13:40

Re: Problem with Firefox configuration

Beitrag von it_usd_goe »

Wow.Thanks a lot for that post.I'm going to try those ways.
Where do i have to place the opsi commands?
ritsovih
Beiträge: 38
Registriert: 20 Mär 2013, 09:25

Re: Problem with Firefox configuration

Beitrag von ritsovih »

I find it easier to handle all deployment logic via a regular batchfile, which I call via an OPSI script with the DosInAnIcon function. The batchfile always produces an exitcode, which gets interpreted with the opsi function Sub_check_exitcode, so I can determine whether the script has run successful or not. I prefer this method, because I already have a pretty extensive set of native (batch, vbs, powershell) windows scripts . This way I don't have to spend my time learning a new (opsi) scripting language and can simply re-use what I already have.

firefox.ins

Code: Alles auswählen

[Initial]
ExitOnError=true
StayOnTop = true
 
[Actions]
requiredWinstVersion >= "4.10.5"
 
DefVar $ProductId$
DefVar $ExitCode$
DefVar $NTVersioninfo$
DefVar $32bitfile$
SetLogLevel=6
; ----------------------------------------------------------------
Set $ProductId$       = "Mozilla Firefox"
; ----------------------------------------------------------------

ShowBitmap  "%ScriptPath%\firefox.png" $ProductId$
Message "Installing Mozilla Firefox"

; OS Version ermitteln  > Win2000
Set $NTVersioninfo$ = GetMsVersionInfo
 
if not ( $NTVersioninfo$ >= "5.1" )
	LogError "Windows version is not compatible" 
		isFatalError
endif
 
	DosInAnIcon_1
	sub_check_exitcode

[DosInAnIcon_1]
%scriptpath%\depot\Install_Mozilla-Firefox.cmd

[sub_check_exitcode]
comment "test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
	comment "looks good: setup program gives exitcode zero"
else
	comment "Setup program gives a exitcode unequal zero: "+$ExitCode$
	if ($ExitCode$ = "1605")
		comment "ERROR_UNKNOWN_PRODUCT	1605	This action is only valid for products that are currently installed."
		comment "Uninstall of a not installed product failed - no problem"
	else
		if ($ExitCode$ = "1641")
			comment "looks good: setup program gives exitcode 1641"
			comment "ERROR_SUCCESS_REBOOT_INITIATED	1641	The installer has initiated a restart. This message is indicative of a success."
			Exitwindows /Reboot
		else
			if ($ExitCode$ = "3010")
				comment "looks good: setup program gives exitcode 3010"
				comment "ERROR_SUCCESS_REBOOT_REQUIRED	3010	A restart is required to complete the install. This message is indicative of a success."
				Exitwindows /Reboot
			else
				logError "Fatal: Setup program gives an unknown exitcode unequal zero: "+$ExitCode$
				isFatalError
			endif
		endif
	endif
endif
Install_Mozilla-Firefox.cmd

Code: Alles auswählen

@Echo off
CLS
SETLOCAL
::---------------------------------------------------------------------------------------------------------------------------------------
::		13-11-2013	ritsovih		Eerste versie
::		Installs Mozilla Firefox on 64 bits Windows 7
::                              General script-logic graceously stolen from MvO (former colleague)
::---------------------------------------------------------------------------------------------------------------------------------------

COLOR 40
ECHO DO NOT CLOSE ANY WINDOWS UNTILL YOU SEE THE CTRL+ALT+DEL SCREEN!!!!

SET PACKAGEDIR=%~dp0
SET PACKAGEDIR=%PACKAGEDIR:~,-1%
SET ERR_LVL2=0
SET ERR_LVL=0
SET ERR_LVL_SCRIPTS=0
SET ERR_LVL_TMP=0
SET ERR_LVL_TOOLS=0

SET CMDNAME=%~nx0
SET CMDNAME=%cmdName:~,-4%
IF NOT EXIST "C:\TMP\APPS." MKDIR C:\TMP\APPS\
SET LOGFILE=C:\TMP\APPS\%CMDNAME%_%RANDOM%
IF NOT EXIST "C:\TOOLS." MKDIR C:\TOOLS
CALL :LOGIT Start %CMDNAME%
CALL :LOGIT PACKAGEDIR=%PACKAGEDIR%
CALL :LOGIT INSTALLPACKAGE=%INSTALLPACKAGE%

::=========================================================================
:MAINPROG
::=========================================================================


CALL :LOGIT Installing Mozilla Firefox
%PACKAGEDIR%\Firefox-Setup-25.0.exe -ms
SET ERR_LVL2=%ERRORLEVEL% 
IF %ERR_LVL%==0 SET ERR_LVL=%ERR_LVL2%
IF /I %ERR_LVL% NEQ 0 (
		IF /I %ERR_LVL% NEQ 3010 GOTO :MAINPROG_EXIT
	)

IF NOT EXIST "c:\program files (x86)\mozilla Firefox\browser\defaults\profile." MKDIR "c:\program files (x86)\mozilla Firefox\browser\defaults\profile"


CALL :LOGIT COPY prefs.js
copy /y %PACKAGEDIR%\prefs.js "c:\program files (x86)\mozilla Firefox\browser\defaults\profile"
:MAINPROG_EXIT
CALL :LOGIT Einde installatie
GOTO :EINDE

::=========================================================================
:EINDE
::=========================================================================
CALL :LOGIT einde ERROR=%ERR_LVL%

EXIT /B %ERR_LVL%


::=========================================================================
:LOGIT
::=========================================================================
SET LOGTIME=%TIME%
SET LOGTIME=%LOGTIME:~,-3%
ECHO %*
ECHO %DATE% %LOGTIME% %* >> %LOGFILE%.txt
:EXIT_LOGIT
GOTO :EOF
Layout packagedir:

Code: Alles auswählen

.
firefox.ins
firefox.png
 |
 --------depot
              |
              ------------------Firefox-Setup-25.0.exe
              ------------------prefs.js
that's just 1 way to do it off course, many ways to Rome, I think opsi even includes a couple of built-in functions for firefox deployment customization. Whatever floats your boat :)
it_usd_goe
Beiträge: 15
Registriert: 17 Okt 2013, 13:40

Re: Problem with Firefox configuration

Beitrag von it_usd_goe »

Thanks ritsovih.
I just set up firefox and copied the prefs.js into my "files" folder.
Now I'm creating the \browser\defaults\profile folder in the winbatch function.
And I copy the prefs.js file via Files-Install function.
Tested and works fine.

Thanks a lot for all those ideas.
Antworten