Citrix Presentation Server 4.0 Deployment Script

The script below is very thorough. Please read through it so that you understand exactly what it does. This script is part of our automated server deployment model.

CMDOW @ /HID
@Echo Off
::------------------------------------------------------------------------------
:: Citrix Presentation Server Deployment
:: -------------------------------------
::
:: Revision History:
::
:: v2.0 9th Feb 2007 by Jeremy.Saunders@au1.ibm.com
:: - Cleared revision history.
::
:: Notes:
:: 1) This script works if you are joining a farm or even creating one. Just
:: toggle the FarmStatus variable to achieve the required results.
:: 2) We test for existing versions of Sun J2RE 1.4.2. Presentation Server
:: requires a minumum of 1.4.2 update 06. If an acceptable version is found, the
:: CTX_USE_EXISTING_JRE property is set to Yes, which tells the Presentation
:: Server installation mechanism to use an existing installation of the Sun JRE.
:: Doing it this way allows us to pre-install a later version of the Sun 1.4.2
:: JRE, such as 1.4.2_13 and above that include the DST patches, etc.
:: If your existing installation of the 1.4.2_xx is faulty or corrupt, this
:: script, and the Presentation Server installation process will not fix it. We
:: are simply checking for the existence of a registry key.
:: 3) The installation of Presentation Server creates 15 anonymous user accounts
:: (Anon000 to Anon014). This script will disable them as per best practice from
:: a security point of view.
:: 4) This script has not been tested on x64 (64 bit) deployments. However, as
:: you can see from the Architecture environment variable, provisions have been
:: made.
::
::------------------------------------------------------------------------------
Echo.
Echo ....Installing Presentation Server 4.x.....
Echo.

:: The following 8 lines are Environment variables that are available to all
:: scripts throughout our automated build process. Some are deleted when the
:: build completes. So you will need to uncomment and customise these lines if
:: you are deploying Presentation Server manually outside the build process, or
:: to an environment that does not contain these variables.
::Set BldSWDrive=S:
::Set FarmStatus=Join
::Set BldDomain=DEMO
::Set BldUser=svr_build
::Set CitrixEdition=Enterprise
::Set CitrixVersion=PS4
::Set DeployOS=W2K3
::Set Architecture=x32

Set ODBCUserName=DEMO\svr_citrix_sql
Set ODBCPassword=Password1
Set LicenseServerName=DC1
Set ServerLocation="http://pnagent.demo.com/Citrix/PNAgent/config.xml"
Set FarmName="Demo Applications"

:: Groups for permissions to ICA-TCP and RDP-TCP listeners.
Set Group1=Perth Citrix Users
Set Group2=Melbourne Citrix Users
Set Group3=Sydney Citrix Users

If /I "%CitrixEdition%"=="Enterprise" Set MFServerType=e
If /I "%CitrixEdition%"=="Advanced" Set MFServerType=a
If /I "%CitrixEdition%"=="Standard" Set MFServerType=s

SET SQLServer=CitrixSQL
SET IMADatabase=CitrixIMA
SET RMDatabase=CitrixRM

Set loglocation=%systemDrive%\bldlogs

if not exist %loglocation% md %loglocation%

Echo.
Echo Deleteing any existing "Citrix" registry keys that may cause the installation of Presentation Server to fail.
SET KEY=HKLM\SYSTEM\CurrentControlSet\
REG DELETE "%KEY%Control\Terminal Server\WinStations\ICA-tcp" /f 2>nul
REG DELETE "%KEY%Control\Citrix" /f 2>nul
REG DELETE "%KEY%Services\ICABrowser" /f 2>nul

Echo.
Echo Creating the File DSN...
Echo [ODBC]>%loglocation%\CitrixSQL.DSN
Echo DRIVER=SQL Server>>%loglocation%\CitrixSQL.DSN
Echo Trusted_Connection=Yes>>%loglocation%\CitrixSQL.DSN
Echo Network=DBMSSOCN>>%loglocation%\CitrixSQL.DSN
Echo DATABASE=%IMADatabase%>>%loglocation%\CitrixSQL.DSN
Echo APP=Citrix IMA>>%loglocation%\CitrixSQL.DSN
Echo SERVER=%SQLServer%>>%loglocation%\CitrixSQL.DSN
Echo Description=Citrix IMA Database>>%loglocation%\CitrixSQL.DSN

set KEY=HKLM\Software\JavaSoft\Java Runtime Environment
set JREUpdate=6

:CheckJavaVersion
IF %JREUpdate% LSS 10 reg query "%KEY%\1.4.2_0%JREUpdate%" >nul 2>&1
IF %JREUpdate% GEQ 10 reg query "%KEY%\1.4.2_%JREUpdate%" >nul 2>&1
IF %ERRORLEVEL% EQU 0 goto JavaExists
set /a JREUpdate+=1
IF %JREUpdate% EQU 21 GOTO NoJava
goto CheckJavaVersion

:NoJava
Set JavaInstalled=No
goto SetPSInstallProperties

:JavaExists
::IF %JREUpdate% LSS 10 echo Java 1.4.2_0%JREUpdate% exists
::IF %JREUpdate% GEQ 10 echo Java 1.4.2_%JREUpdate% exists
Set JavaInstalled=Yes

:SetPSInstallProperties
Set SetupProperties=/qb
Set SetupProperties=%SetupProperties% /Lv* %loglocation%\CitrixPS.Log
Set SetupProperties=%SetupProperties% CTX_MF_FARM_SELECTION=%FarmStatus%
Set SetupProperties=%SetupProperties% CTX_MF_NEW_FARM_NAME=%FarmName%
Set SetupProperties=%SetupProperties% CTX_MF_JOIN_FARM_DB_CHOICE=Direct
Set SetupProperties=%SetupProperties% CTX_MF_CREATE_FARM_DB_CHOICE=Thirdparty
Set SetupProperties=%SetupProperties% CTX_MF_ODBC_USER_NAME="%ODBCUserName%"
Set SetupProperties=%SetupProperties% CTX_MF_ODBC_PASSWORD=%ODBCPassword%
Set SetupProperties=%SetupProperties% CTX_MF_ODBC_RE_ENTERED_PASSWORD=%ODBCPassword%
Set SetupProperties=%SetupProperties% CTX_MF_LICENSE_SERVER_NAME=%LicenseServerName%
Set SetupProperties=%SetupProperties% CTX_MF_USER_NAME=%BldUser%
Set SetupProperties=%SetupProperties% CTX_MF_DOMAIN_NAME=%BldDomain%
Set SetupProperties=%SetupProperties% CTX_MF_SHADOWING_CHOICE=Yes
Set SetupProperties=%SetupProperties% CTX_MF_SERVER_TYPE=%MFServerType%
Set SetupProperties=%SetupProperties% CTX_MF_SHADOW_PROHIBIT_REMOTE_ICA=No
Set SetupProperties=%SetupProperties% CTX_MF_LAUNCH_CLIENT_CD_WIZARD=No
Set SetupProperties=%SetupProperties% CTX_MF_SILENT_DSNFILE=%loglocation%\CitrixSQL.DSN
Set SetupProperties=%SetupProperties% CTX_MF_ENABLE_VIRTUAL_SCRIPTS=Yes
Set SetupProperties=%SetupProperties% CTX_USE_EXISTING_JRE=%JavaInstalled%
Set SetupProperties=%SetupProperties% CTX_MF_ONLY_LAUNCH_PUBLISHED_APPS=No
Set SetupProperties=%SetupProperties% CTX_MF_ADD_LOCAL_ADMIN=Yes
Set SetupProperties=%SetupProperties% CTX_ADDLOCAL="All"
Set SetupProperties=%SetupProperties% SERVER_LOCATION=%ServerLocation%
Set SetupProperties=%SetupProperties% REBOOT=ReallySuppress

Echo.
Echo Installing Citrix Presentation Server 4.0...
Echo.
msiexec /i "%BldSWDrive%\Citrix%CitrixVersion%\%DeployOS%\%Architecture%\MetaFrame Presentation Server\MPS.msi" %SetupProperties%

:: Start the MetaFrame COM Server service...
:: Note: This is needed if you want to install components such as Conferencing
:: Manager.
net start | FIND "MetaFrame COM Server" > nul
IF errorlevel 1 net start "MetaFrame COM Server" 2>nul

Echo.
Echo Installing the Access Suite Console...
Echo.

Set SetupProperties=/qb
Set SetupProperties=%SetupProperties% /Lv* %loglocation%\CitrixASC.log
Set SetupProperties=%SetupProperties% REBOOT=ReallySuppress

msiexec /i "%BldSWDrive%\Citrix%CitrixVersion%\%DeployOS%\%Architecture%\Administration\Access Suite Console\CitrixMMC.msi" %SetupProperties%

:: If it is the Enterprise version, install Conferencing Manager and configure
:: the Resource Manager DSN.
IF /I NOT "%CitrixEdition%"=="Enterprise" GOTO DisableRM

:: If it is the Packaging server skip the installation of Conferencing manager
:: and configuring the Resource Manager DSN.
IF /I "%UDF:~0,6%"=="CTXPKG" GOTO DisableAnon

Echo.
Echo Install Conferencing Manager 4.0.
Echo.
@call "%~dp0InstCM4.cmd"

Echo.
Echo Create the Citrix Resource Manager DSN for connection to the Summary database.
Echo.
SET KEY=HKLM\SOFTWARE\ODBC\ODBC.INI\RMSummaryDatabase
REG ADD "%KEY%" /v Driver /d %SystemDrive%\WINDOWS\system32\SQLSRV32.dll /f
REG ADD "%KEY%" /v Server /d %SQLServer% /f
REG ADD "%KEY%" /v Database /d %RMDatabase% /f
REG ADD "%KEY%" /v Description /d "Resource Manager Summary Database" /f
REG ADD "%KEY%" /v Trusted_Connection /d Yes /f
SET KEY=HKLM\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources
REG ADD "%KEY%" /v RMSummaryDatabase /d "SQL Server" /f

GOTO DisableAnon

:DisableRM
Echo.
Echo Rename the Resource Manager Plugin to remove the Unlicensed Server errors on non-Enterprise server deployments.
Echo.
REN "%ProgramFiles%\Citrix\Administration\Plugins\ResourceManager.jar" "ResourceManager.unused"

:DisableAnon
Echo.
Echo Disabling the 15 anonymous user accounts created by the Presentation Server installation...
Echo.
SET count=1
FOR /F "eol=- tokens=1-3 delims= " %%i in ('net user') do (call :ProcessUserAccounts %%i %%j %%k)
GOTO Listeners

:ProcessUserAccounts
Set Account=%1
IF /I "%Account:~0,4%"=="Anon" NET USER %1 /active:no
Set Account=%2
IF /I "%Account:~0,4%"=="Anon" NET USER %2 /active:no
Set Account=%3
IF /I "%Account:~0,4%"=="Anon" NET USER %3 /active:no
set /a count+=1
GOTO :EOF

:Listeners
:: We use the TsConSec utility to set the permissions of the ICA and RDP
:: listeners. This is the only automated method that can be used that is fully
:: compatible between all Windows Operating Systems. It can be downloaded from
:: http://portal.loginconsultants.nl/forum/index.php?board=16. It is copied to
:: the %SystemRoot% folder during the initial part of the server build process.
ECHO Modifying permissions of ICA and RDP listeners>%loglocation%\Listeners.txt
ECHO ---------------------------------------------->>%loglocation%\Listeners.txt

IF /I "%DeployOS%"=="W2K" GOTO W2K
IF /I "%DeployOS%"=="W2K3" GOTO W2K3

GOTO Finish

:W2K
Echo Remove Everyone from the ICA-Tcp listener...>>%loglocation%\Listeners.txt
TsConSec.exe /t:ICA /a:Everyone /x: /Q>>%loglocation%\Listeners.txt

Echo Remove Guests from the ICA-Tcp listener...>>%loglocation%\Listeners.txt
TsConSec.exe /t:ICA /a:Guests /x: /Q>>%loglocation%\Listeners.txt

Echo Add "%BldDomain%/%Group1%" to the ICA-Tcp listener with deny permissions...>>%loglocation%\Listeners.txt
TsConSec.exe /t:ICA /d:%BldDomain% /a:"%Group1%" /x:UG /Q>>%loglocation%\Listeners.txt

Echo Add "%BldDomain%/%Group1%" to the RDP-Tcp listener with deny permissions...>>%loglocation%\Listeners.txt
TsConSec.exe /t:RDP /d:%BldDomain% /a:"%Group1%" /x:UG /Q>>%loglocation%\Listeners.txt

GOTO Finish

:W2K3
:: Unlike Windows 2000, by default Windows 2003 only allows members of the
:: Remote Desktop Users and Administrators groups to connect via ICA and RDP.
:: Therefore, we currently do not run TsConSec for Windows 2003 server builds.
:: However, the structure is in place should a customer wish to lock it down
:: further.

:Finish
Exit /B

 


    9th April 2007