In the article Terminal Server Environment Basic Concepts I had explained that a server should be installed silently. Therefore scripts should be created to accomplish this basic concept rule. In this article I will discuss and describe how to perform an unattended installation of Citrix Presentation Server.
Which Version of Presentation Server?
In the last few years Citrix has released several versions of Presentation Server. Luckily, the unattended parameters were not changed in the latest versions, only a few new parameters were added for some new functionality. So this article can be used for Citrix Metaframe XP, MPS3 and CPS4.
The installation of Presentation Server can be divided into two. The first part is the installation of the software where the data store and the farm are created. This is followed by other installations where the server joins the farm (so only the Presentation software is installed).
First installation Preparations
As mentioned above, in this part of our installation procedure, the database is created for the Citrix farm. In small environments Access or MSDE can be used, but in the bigger environments normally SQL is used.
When installing Presentation Server using SQL the database should already be available for installation of Presentation Server. The creation of the database can be done manually on the SQL server, but this can also be done unattended via scripting.
Therefore the SQL command osql.exe can be used. With this tool you can carry out SQL commands from a command line. Therefore some kind of SQL script is necessary which will be called by the osql.exe. Figure 1 shows an example of one for creating a new database. Values in Figure 1 surrounded by "#" should be replaced with real information where:
Should be replaced with the database name within SQL for the datastore
The file location of the SQL database files on the SQL server. Normally something like <DRIVELETTER>:\MSSQL\DATA
The file location of the SQL log files on the SQL server. Normally something like <DRIVELETTER>:\MSSQL\LOG
- #CTX_ ODBC_USER_NAME#
This parameter is the owner of the database. This account will be created as an SQL account.
- #PWD_CTX_ ODBC_PASSWORD#
The password for the above mentioned user.
The template uses the datastore name to create the files for this database. It is advisable to use the same name for file creation as the SQL database name.
In big environments these values can be replaced by variables via scripting, so the same script can be used on more environments. Change the parameters SIZE, MAXGROWTH and FILEGROWTH to match the needs of your infrastructure.
Figure 1: Example of new database SQL script for osql.exe
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'#CTX_DATASTORENAME#')
PRINT 'Database exists'
RAISERROR ('DataBase #CTX_DATASTORENAME# already exists!', 16, 1)
PRINT 'Database does not exists'
CREATE DATABASE #CTX_DATASTORENAME#
( NAME = '#CTX_DATASTORENAME#_dat',
FILENAME = '#SQL_DB_DATAPATH#\#CTX_DATASTORENAME#.mdf',
SIZE = 50MB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 10% )
( NAME = '#CTX_DATASTORENAME#_log',
FILENAME = '#SQL_DB_LOGPATH#\#CTX_DATASTORENAME#.ldf',
SIZE = 25MB,
MAXSIZE = UNLIMITED,
FILEGROWTH = 10% )
EXEC sp_addlogin '#CTX_ ODBC_USER_NAME#', '#PWD_CTX_ ODBC_PASSWORD#', '#CTX_DATASTORENAME#'
EXEC sp_changedbowner '#CTX_ ODBC_USER_NAME#'
After you have finished modifying the sql script for your own environment you can execute the OSQL command from any machine with the following parameters:
-b , the command will abort when errors are detected. Can be used for error handling in scripts.
-S , the SQL server name where the database need to be created
-U , username with right to connect to the SQL and creating databases, normally SA account
-P ,password for the username
-i ,the sql script file which should be executed.
Using the above variables you might use the following command:
OSQL -b -S %SQL_SRV% -U %SQL_SAUSR% -P %PWD_SQL_SA% -i %TEMP%\NEW_DB.sql
So we have made it possible to create the database for the datastore. Logically we need to connect to this database during the installation of Metaframe. This connection is made via ODBC, so we need to create an ODBC file, which will be used by the Presentation server installation. An ODBC File has the extension .DSN and contains all the information needed for the ODBC driver to connect to the database. (The password will be given as parameter in the Presentation Server installation.) The DSN file is a simple text file with the following format:
Also for this file, the variables need to be changed to reflect the real values in your environment. If you choose to also script this file, you could use the "ECHO" dos command to create an unattended file. See the example in Figure 2.
Figure 2: Example of creating an unattended DSN file
ECHO DRIVER=SQL Server>>"%TEMP%\SQL.DSN"
ECHO APP=Citrix IMA>>"%TEMP%\SQL.DSN"
Installing Required Helper Programs
To install Citrix Presentation Server successfully some software needs to already be installed on the server. Logically, this software also should be installed silently with no manual interaction.
For Presentation Server 4 on Windows 2003, MSI installer 3.1 (already included within SP1) and Java Runtime Environment (JRE) 1.4.2 are required.
Because MSI installer 3.1 is provided in the hotfix format it is easy to create an unattended installation. Hotfixes can be installed with different parameters depending on the type of hotfix. The most commonly used are the “–q –m and –z” options or the “/quiet /passive and /norestart” options. Installing an unattended MSI installer can be done using the following command line:
%INSTALLDIR%\WindowsInstaller-KB893803-v2-x86.exe /quiet /norestart
For more information about command line parametersplease look at the following support on the Microsoft Support website.
The second required component for Citrix Presentation Server is the Java Runtime Environment. On CPS4 CD version 1.4.2 it is included as an executable. However like most applications the installation actually is an MSI file with some additional files combined into one executable. As already known, MSI files are perfect for silent installations. The only job to do is to get the content out of that executable. When executing the file the content is extracted and placed in a temporary directory or often %userprofile%\Local Settings\Application Data\<GUID> on the system. So to get those files just start the application on one system. As soon as the first installation Window is displayed all files are available on the system in the temporary directories. Copy all the files and just use the MSIEXEC commands for the silent installation. Combined with this could be the command line for installing JRE "Java 2 Runtime Environment, SE v1.4.2_06.msi" /qb-! REBOOT="ReallySuppress" /liewa "%LOGFILE%.LOG".
Database parameters for SQL
Now that the SQL database is available and the helper applications are scripted we are ready for the Presentation Server silent installation. First let's start with the parameters for creating a farm using SQL for the datastore.
First we need to specify which kind of database we are using. In the parameters Citrix has built in two options: third-party database or a local database. For SQL please use the third party database option (Read it as a non-local database). Accomplish this with the parameter:
CTX_MF_CREATE_FARM_DB_CHOICE with the value Thirdparty.
Obviously the username and password needs to be specified to connect to the SQL server for filling the earlier created database. Use here the same username that you created during the creation of the database. Put this user behind the parameter CTX_MF_ODBC_USER_NAME. The password needs to be given with the parameter CTX_MF_ODBC_PASSWORD. There is also a parameter CTX_MF_ODBC_RE_ENTERED_PASSWORD, but because we already created this user with the osql command this parameter is not necessary.
The last parameter for the database is the pointer to the file with the information about the database server and which database. We have already saved all that information in the DSN file earlier in this article. With the parameter CTX_MF_SILENT_DSNFILE we point the installation to that file.
In this first article of the unattended Citrix installation we have created the database for the datastore unattended. Also the needed DNS connection file is built up automatically. The required helper programs were also installed silently. Also the first parameters related to the database have been described in this article. In the second part of this series I will continue with the remaining parameters for creating and joining the farm. Also the local database parameters will be described in the next article.