Administer > Content utilities > IDK scripts > Installation hooks

Installation hooks

The installation hooks are scripts that reside in the ism/pkg subdirectory. (Some documents refer to the installation hooks as “packaging scripts.”) The installation hooks are run at certain stages during the installation and uninstallation of applications on managed servers.

Creating installation hooks

The ISMTool --new command creates the following installation hooks:

Unix:

ism/pkg/	
	ism_check_install
	ism_post_install
	ism_post_uninstall				
	ism_pre_install	
	ism_pre_uninstall


Windows:

ism\pkg\	
	ism_post_install.cmd
	ism_post_uninstall.cmd
	ism_pre_install.cmd	
	ism_pre_uninstall.cmd
 

To customize the installation hooks, you modify them with a text editor. Although you may edit the installation hooks, you cannot change their file names.

The default ism_pre_install and ism_post_uninstall hooks are just stubs; they perform no actions. The default ism_post_install hook calls the ism_configure and ism_start control scripts. The default ism_pre_uninstall hook calls the ism_stop control script. Note that the control scripts are not created automatically by the ISMTool; you must create them with a text editor. (See Control scripts.)

For the contents of the default installation hooks created by the --build command, see the following sections:

Check installation hook

Some native packaging engines support the ism_check_install hook directly; others do so implicitly with the ism_pre_install hook. The ISMTool maps the check_install feature onto the native packaging engine. If the check_install script returns a non-zero code, the install is halted.

Invocation of installation hooks

When you install (or uninstall) the application of an ISM onto a managed server, the native packaging engine on the server invokes the installation hooks. (You do not run the installation hooks directly.) For example, on a Linux system, the rpm utility invokes ism_pre_install immediately before it installs the application bits and invokes ism_post_uninstall right after it removes the bits.

See also Invocation of installation scripts and hooks.

Installation hooks and ZIP packages

Unlike some other packaging engines, the ZIP packaging engine used by Server Automation does not support installation hooks. If the ZIP packaging engine is specified and the installation hook files are not empty, the ISMTool generates a warning and ignores the installation hook files.

ZIP packages and installation directories

The ZIP packages created by the IDK are not relocatable. In other words, the same ZIP package cannot be used to install multiple instances of an application in different directories on a single managed server. Therefore, if the end user changes the ZIP package’s Install Path field in the SA Client, the package installation will fail. To change the installation directory, the ISM developer specifies a new path with the --prefix or --ctlprefix option, builds a new ISM, and uploads the new ISM to the core. (For Windows NT4, these options are required and cannot specify variables.)

As a best practice for ZIP packages, the ISM developer should include a warning in the ISM’s description similar to the following: “WARNING: Do not change the Install Path of this package.”

Installation hook functions

You can customize the installation hooks to perform actions such as those listed in the following table.

Installation hook functions

Install hook

Common functions

ism_pre_install

Create required directories, create users, set directory permissions

ism_post_install

Call ism_configure control script, call ism_start control script (to start a web server, for example)

ism_pre_uninstall

Call ism_stop control script (to stop a server)

ism_post_uninstall

Do any required clean up

Scripts for control-only ISMs

If you specify the --skipApplicationPkg option, the ISMTool will not build the application package, enabling the creation of a control-only ISM. You can use this feature to build a controller for an application that is not installed or packaged with the ISMTool. Examples are controllers for core operating system functions, currently running applications that cannot be packaged, and specialized hardware.

During the installation and uninstallation of a control-only ISM, the ism_ctl_post_install and ism_ctl_pre_uninstall scripts are run. (The scripts are run for all ISMs, but typically you specify them only for control-only ISMs.) Because these scripts are not generated by the ISMTool, you must create them before running the --build command. The following listing shows the required names and locations of these scripts:

Unix:

ism/pkg/
	. . .	
	ism_ctl_post_install
	ism_ctl_pre_uninstall	

Windows:

ism\pkg\
	. . .
	ism_ctl_post_install.cmd
	ism_ctl_pre_uninstall.cmd	

Location of installation hooks on managed servers

On your development system, the --build command bundles the installation hooks into the ISM's control package. On the managed server, the contents of the control package are installed into the directory indicated by the ctlprefix of the ISM. By default, the installation hooks are installed into the following directory:

Unix:

/var/opt/OPSWism/<ism-name>/pkg

Windows:

%ProgramFiles%\OPSWism\<ism-name>\pkg

To change the default directory of the installation hooks, specify the --ctlprefix option before building and uploading the ISM. If you specify the ctlprefix as follows, for example, the installation hooks will be installed in /usr/local/ntp-4.1.2/pkg:

ismtool --ctlprefix /usr/local ntp-4.1.2

Default installation hooks for Unix

The default ism_pre_install hook:

#!/bin/sh
#
# ISM Pre Install Script
#
. ‘dirname $0‘/../env/ism.sh

The default ism_post_install hook:

#!/bin/sh
#
# ISM Post Install Script
#
. ‘dirname $0‘/../env/ism.sh
if [ -x ${ISMDIR}/control/ism_configure ]; then
${ISMDIR}/control/ism_configure
fi
if [ -x ${ISMDIR}/control/ism_start ]; then
${ISMDIR}/control/ism_start
fi

The default ism_pre_uninstall hook:

#!/bin/sh
#
# ISM Pre Uninstall Script
#
. ‘dirname $0‘/../env/ism.sh
if [ -x ${ISMDIR}/control/ism_stop ]; then
${ISMDIR}/control/ism_stop
fi

The default ism_post_unininstall hook:

#!/bin/sh
#
# ISM Post Uninstall Script
#
. ‘dirname $0‘/../env/ism.sh

Default installation hooks for Windows

The default ism_pre_install.cmd hook:

@echo off
REM
REM ISM Pre Install Hook
REM
SETLOCAL
REM
REM %1 specifies the full path to the ISM.CMD file
REM Call ISM.CMD to define ISM environment variables
REM
call %1
ENDLOCAL


The default ism_post_install.cmd hook:

@echo off
REM
REM ISM Post Install Script
REM
SETLOCAL
REM
REM %1 specifies the full path to the ISM.CMD file
REM Call ISM.CMD to define ISM environment variables
REM
call %1
REM
REM Call the ISM’s configure script
REM
IF EXIST "%ISMDIR%\control\ism_configure.cmd"
call "%ISMDIR%\control\ism_configure.cmd"
REM
REM Call the ISM’s start script
REM
IF EXIST "%ISMDIR%\control\ism_start.cmd"
call "%ISMDIR%\control\ism_start.cmd"
ENDLOCAL


The default ism_pre_uninstall.cmd hook:

@echo off
REM
REM ISM Pre Uninstall Hook
REM
SETLOCAL
REM
REM %1 specifies the full path to the ISM.CMD file
REM Call ISM.CMD to define ISM environment variables
REM
82 Chapter 6
call %1
REM
REM Call the ISM’s stop script
REM
IF EXIST "%ISMDIR%\control\ism_stop.cmd"
call "%ISMDIR%\control\ism_stop.cmd"
ENDLOCAL


The default ism_post_unininstall.cmd hook:

@echo off
REM
REM ISM Post Uninstall Script
REM
SETLOCAL
REM
REM %1 specifies the full path to the ISM.CMD file
REM Call ISM.CMD to define ISM environment variables
REM
call %1