Wilco van Bragt - LinkeIn Wilco van Bragt - Twitter rssa 

How to install Citrix Presentation Server unattended? Part 1

Introduction

In the article Basic Concepts of a Terminal Server I already 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 Citrix Presentation Server can be installed unattended.

Which version of Presentation Server




 

The last years Citrix released several version of Presentation Server. Happily the unattended parameters are not changed in the latest versions, only a few new parameters were added for 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 parts. The first installation of the software where also the data store and the farm are created. Followed by the other installations where the server joins the farm (so only the Presentation software is installed).

First installation Preparations 

As just mentioned in this version also the database is created for the Citrix farm. In small environments Access or MSDE could be used, but in the bigger environments normally SQL is used.

When installing Presentation server using a SQL the database should be already available for installation of Presentation server. The creation of the database could be done manual on the SQL server, but also this part can be done unattended via scripting.

Therefore the SQL commando osql.exe can be used.  With this tool you can carry out SQL command 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 for creating a new database. Values in this example with # should be replaced with real information where,

#CTXDATASTORENAME#

should be replaced with the database name within SQL for the datastore

#SQL_DB_DATAPATH#

the file location of the SQL database files on the SQL server. Normally something like <DRIVELETTER>:\MSSQL\DATA

 

#SQL_DB_LOGPATH#

the file location of the SQL log files on the SQL server. Normally something like <DRIVELETTER>:\MSSQL\LOG

 

#CTX_ ODBC_USER_NAME#

This parameter will be the owner of the database. This account will be created as a SQL account.

 

#PWD_CTX_ ODBC_PASSWORD#

 

The password for the above mentioned user.

 

The template uses the datastore name also, to create the files for this database. It is advisable to use the same name for the 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 the needs of your infrastructure.

 USE master
GO

IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'#CTX_DATASTORENAME#')
 BEGIN
  USE master
  PRINT 'Database exists'
  RAISERROR ('DataBase #CTX_DATASTORENAME# already exists!', 16, 1)
 END
ELSE
 PRINT 'Database does not exists' 

GO

CREATE DATABASE #CTX_DATASTORENAME#
ON
( NAME = '#CTX_DATASTORENAME#_dat',
   FILENAME = '#SQL_DB_DATAPATH#\#CTX_DATASTORENAME#.mdf',
   SIZE = 50MB,
   MAXSIZE = UNLIMITED,
   FILEGROWTH = 10% )
LOG ON
( NAME = '#CTX_DATASTORENAME#_log',
   FILENAME = '#SQL_DB_LOGPATH#\#CTX_DATASTORENAME#.ldf',
   SIZE = 25MB,
   MAXSIZE = UNLIMITED,
   FILEGROWTH = 10% )
GO

USE #CTX_DATASTORENAME#

EXEC sp_addlogin '#CTX_ ODBC_USER_NAME#', '#PWD_CTX_ ODBC_PASSWORD#', '#CTX_DATASTORENAME#'

EXEC sp_changedbowner '#CTX_ ODBC_USER_NAME#'

Figure 1: Example of new database SQL script for osql.exe

After the sql script is filled in 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 variables this could the command:

OSQL -b -S %SQL_SRV% -U %SQL_SAUSR% -P %PWD_SQL_SA% -i %TEMP%\NEW_DB.sql

So we 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. A ODBC File has the extension .DSN and exist of all information to use the needed ODBC driver and 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:

[ODBC]

DRIVER=SQL Server

UID=%CTX_ODBC_USER_NAME%

WSID=%COMPUTERNAME%

DATABASE=%CTX_DATASTORENAME%

APP=Citrix IMA

SERVER=%SQL_SRV%

Also for this file the variables need to be changed by the real values in your environment. If your also scripting this file you could use the ECHO dos command to create this file unattended. This is being written down in figure 2.

ECHO [ODBC]>"%TEMP%\SQL.DSN"

ECHO DRIVER=SQL Server>>"%TEMP%\SQL.DSN"

ECHO UID=%CTX_MF_ODBC_USER_NAME%>>"%TEMP%\SQL.DSN"

ECHO WSID=%COMPUTERNAME%>>"%TEMP%\SQL.DSN"

ECHO DATABASE=%CTX_DATASTORENAME%>>"%TEMP%\SQL.DSN"

ECHO APP=Citrix IMA>>"%TEMP%\SQL.DSN"

ECHO SERVER=%SQL_SRV%>>"%TEMP%\SQL.DSN"

Figure 2: Example of creating the DSN file unattended

Installing required Helper Programs

To install Citrix Presentation Server successfully some software need already be installed on the server. Logically also this software should be installed silent 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 the different parameters depending on the type of hotfix. But most used are the “–q –m and –z” option or the “/quiet /passive and /norestart” option. Installing MSI installer unattended could be done using the following command line %INSTALLDIR%\WindowsInstaller-KB893803-v2-x86.exe /quiet /norestart. For more information about command line parameters can be found in a support article on the Micrsoft Support website.

The second required component for Citrix Presentation Server is the Java Runtime Environment. On the CPS4 CD version 1.4.2 is included as an executable. However like more application the installation actually is a MSI file with some additional files combined in one executable. As already known MSI files are perfect for silent installations. Just one job to do is to get the content outside that executable. When executing the file the content is extracted and place 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 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 the creation of the SQL database is available and the helper applications are scripter we are ready for the Presentation Server silent installation. First lets 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 build in two options: third-party database or a local database. For SQL we are using a third party database (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. Fill 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 already saved all that information in a DSN file earlier in this article. With the parameter CTX_MF_SILENT_DSNFILE we point the installation to that file.

Conclusion

In this first article of the unattended Citrix installation we can create the database for the datastore unattended. Also the needed DNS connection file is build up automatically. For the installation of Presentation server can start also the required helper applications are installed silent. Also the first parameters related to the database are described in this article. In the second article I will continue with the remaining parameters for creating and joining the farm. Also the local database parameters will be described in that second article.

Article previous published at MSTerminalServices.org.