Previous     Contents     Index     Next     
Setup Util Programmer's Guide



Chapter 6   Writing Post-Installation Programs


This chapter shows you how to use post-installation programs to automatically configure your product. It contains the following sections:



Overview of Post-Installation Programs

Post-installation programs make use of the information gathered by pre-installation programs. This data is stored in the installation cache and is used to perform configuration operations.

The specific contents of an installation cache are determined by the pre-installation program, but might include LDAP URLs, base DNs, and passwords. Typically, this information is used to prepare products for their initial use. Post-installation programs can copy information into a Directory Server, initialize configuration files, or perform any other setup tasks that utilize the user input gathered during pre-installation.


Requirements for Post-Installation Programs

Keep the following rules in mind when writing post-installation programs:

  • A post-installation program cannot be interactive and should write to standard output when necessary.

  • If you are installing a server, your post-installation program must create a Server Instance Entry (SIE) in the Directory Server. See Chapter 8 "Interacting with the Directory Server" for more information.

  • A post-installation program must explicitly return an exit value of 0 upon successful completion. It can return any non-zero value to indicate unsuccessful completion.



Writing a UNIX Post-Installation Program

On UNIX, a post-installation program is a stand-alone application written in any language you like. The program is selected by specifying the PostInstall directive in your package information file.

When the Common Install Shell finishes copying files, it starts the post-installation program uses the -f parameter to pass the filename of the installation cache to it. The post-installation program then reads the cache file and configures the product.

Package information files are discussed in Chapter 3 "Information Files."


Sample Post-Installation Program

In the following code example, The post-installation program uses setupInsertPluginSchemaEntries() and setupUpdateLdifEntries() to import an LDIF file and a schema file into the configuration directory.

Code Example 6-1 contains the source code for postinstall.cc, the post-installation program.


main()
{
   char ldifFile[500], schemaFile[500];
   char *userpwd, *userid, *ldapURL;
   Ldap *ldap;
   strcpy(ldifFile, "c:\setup\import.ldif");
   strcpy(schemaFile, "c:\setup\import-schema.conf");
   userid = setupGetInfString(productNickname, "ldapUser", " ",
                              cacheFile);
   userpwd = setupGetInfString(productNickname, "ldapPwd", " ",
                               cacheFile);
   ldapURL = setupGetInfString(productNickname, "ldapURL", " ",
                               cacheFile);
   createLdap(&ldap, ldapURL, userid, userpwd, NULL, NULL);
   setupInsertPluginSchemaEntries(ldapURL, userid, userpwd,
                                  schemaFile);
   setupUpdateLdifEntries (ldap, NULL, ldifFile, NULL);
}

"> Code Example 6-1 Source code for postinstall.cc, the post-installation program.

main()
{
   char ldifFile[500], schemaFile[500];
   char *userpwd, *userid, *ldapURL;
   Ldap *ldap;
   strcpy(ldifFile, "c:\setup\import.ldif");
   strcpy(schemaFile, "c:\setup\import-schema.conf");
   userid = setupGetInfString(productNickname, "ldapUser", " ",
                              cacheFile);
   userpwd = setupGetInfString(productNickname, "ldapPwd", " ",
                               cacheFile);
   ldapURL = setupGetInfString(productNickname, "ldapURL", " ",
                               cacheFile);
   createLdap(&ldap, ldapURL, userid, userpwd, NULL, NULL);
   setupInsertPluginSchemaEntries(ldapURL, userid, userpwd,
                                  schemaFile);
   setupUpdateLdifEntries (ldap, NULL, ldifFile, NULL);
}

Code Example 6-2 and Code Example 6-3 show sample import.ldif and import-schema.conf files.


dn: o=ISP
objectClass: top
objectClass: organization
objectClass: nsManagedISP
o: ISP
nsNumDomains: 1

dn: uid=fred, o=ISP
objectClass: top
objectClass: person
objectClass: organizationalPerson
uid: fred
userPassword: thompson
cn: Fred Thompson
sn: Thompson
givenName: Fred
telephoneNumber: 650.555.1212
...

"> Code Example 6-2 A sample import.ldif file.

dn: o=ISP
objectClass: top
objectClass: organization
objectClass: nsManagedISP
o: ISP
nsNumDomains: 1

dn: uid=fred, o=ISP
objectClass: top
objectClass: person
objectClass: organizationalPerson
uid: fred
userPassword: thompson
cn: Fred Thompson
sn: Thompson
givenName: Fred
telephoneNumber: 650.555.1212
...


attribute father father-oid 1.3.6.1.4.1.1466.115.121.1.15
attribute mother mother-oid 1.3.6.1.4.1.1466.115.121.1.15

objectclass familyTree
   superior inetOrgPerson
      allows
         father,
         mother
...

"> Code Example 6-3 A sample import-schema.conf file.

attribute father father-oid 1.3.6.1.4.1.1466.115.121.1.15
attribute mother mother-oid 1.3.6.1.4.1.1466.115.121.1.15

objectclass familyTree
   superior inetOrgPerson
      allows
         father,
         mother
...



Writing a Windows NT Post-Installation Program

On Windows NT, a post-installation program is part of a DLL containing a pre-installation program and dialog boxes. You should write the post-installation program using the same development environment that you used to create the rest of the DLL. The program is initialized by specifying the PostInstall directive in your package information file.

When the Common Install Shell finishes copying files, it starts the post-installation program using the -f parameter to pass the filename of the installation cache to it. The post-installation program then reads the cache file and configures the product.

Package information files are discussed in Chapter 3 "Information Files."


Previous     Contents     Index     Next     
Copyright (C) 2005 Red Hat, Inc. All rights reserved.
This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/

Last Updated September 21, 2001