A subset control program (SCP) is called
by the
setld
utility when installing or deleting your product
kit.
This chapter describes common tasks required to write subset control
programs.
Note
This chapter applies only if you are creating a subset control program. Subset control programs are optional for user product kits and required for kernel product kits. If you are not creating a subset control program, go to Chapter 5.
This chapter discusses the following topics:
Introducing subset control programs (Section 4.1)
Creating SCP source files (Section 4.2)
Setting up initial SCP processing (Section 4.3)
Working in a cluster environment (Section 4.4)
Working in a DMS environment (Section 4.5)
Associating SCP tasks with
setld
processing
phases (Section 4.6)
Determining subset installation status (Section 4.7)
Stopping the installation (Section 4.8)
Creating SCPs for different types of product kits (Section 4.9)
4.1 Introducing Subset Control Programs
A subset control program (SCP) performs special tasks beyond the basic
installation tasks managed by the
setld
utility.
The following
list includes some of the reasons why you might write a subset control program:
Some of your kit's files have to be customized before the product will work properly.
You want to register a device driver and statically or dynamically configure it.
You need to establish nonstandard permissions or ownership for certain files.
Your kit requires changes in system files such as
/etc/passwd
.
A subset control program can perform all of these tasks.
Caution
Code your subset control program so that it can run more than once without causing operational problems. This does not mean that you must repeat the SCP tasks, but that multiple executions will not cause the SCP to fail or to corrupt existing files.
Remove any code from existing SCPs that refers to
subset-id.lk
orsubset-id.dw
files.
Use the
DEPS
field in the subset control file (subset_id.ctrl
) for subset dependency processing.Do not use the
subset-id.lk
files to determine subset dependencies.Use the library routines described in Table 4-3 to determine if a subset is installed.
In the current version of the operating system,
subset-id.dw
files are no longer created. Use the library routines described in Table 4-3 to determine if a subset is corrupt.
See Section 4.7 for more information about determining subset installation status.
Create one subset control program for each subset that requires special
handling during installation.
You can write the program in any programming
language, but your subset control program must be executable on all platforms
on which the kit can be installed.
If your product works on more than one
hardware platform, you cannot write your subset control program in a compiled
language.
For this reason, it is recommended that you write your subset control
program as a script for
/sbin/sh
.
All of the examples in
this chapter are written in this way.
Keep your subset control programs short. If written as a shell script, a subset control program should be under 100 lines in length. If your subset control program is lengthy, it is likely that you are trying to make up for a deficiency in the architecture or configuration of the product itself.
Note
Subset control programs should not require any interactive responses, and should not generate errors when run repeatedly.
Place all subset control programs that you write in the
scps
directory, a subdirectory of the
data
directory.
Each subset control program's file name must match the subset name to which
it belongs, and it must end with the
scp
suffix.
For example,
the ODB product defines two subsets, named
OATODB100
and
OATODBTEMPS100
.
If each of these subsets required a subset control
program, the source file names would be
OATODB100.scp
and
OATODBTEMPS.scp
.
When you produce the subsets as described in
Chapter 5,
the
kits
utility copies the subset control programs from
the
./data/scps
directory to the
./output/instctrl
directory.
If a subset has no SCP, the
kits
utility creates an empty subset control program file for it in the
./output/instctrl
directory.
4.3 Setting Up Initial SCP Processing
Your subset control program should perform the following tasks within the program:
Including library routines (Section 4.3.1)
Setting global variables (Section 4.3.2)
The following sections describe the resources available to
perform these tasks.
4.3.1 Including Library Routines in Your SCP
The operating system provides a set of routines in the form of Bourne
shell script code located in the
/usr/share/lib/shell
directory.
Do not copy these routines into your subset control program.
This would prevent
your kit from receiving the benefit of enhancements or bug fixes made in future
releases.
Use the following syntax to include these library routines:
SHELL_LIB=${SHELL_LIB:-/usr/share/lib/shell} . $SHELL_LIB/lib_name
This specific coding lets you use newer versions of the shell library if they are present in alternate locations.
In the previous example, lib_name is one of the shell scripts specified in one or more of the following tables.
Table 4-1
lists library routines in the
libscp
shell script.
Table 4-1: SCP Library Routines
Purpose | Library Routine |
Architecture determination | STL_ArchAssert |
Dependency locking | STL_LockInit
[Footnote 2]
|
STL_DepLock
[Footnote 2] |
|
STL_DepUnLock
[Footnote 2] |
|
Dataless environment determination | STL_IsDataless |
STL_NoDataless |
|
Forward symbolic linking | STL_LinkCreate
[Footnote 3]
|
STL_LinkRemove
[Footnote 3] |
|
Backward symbolic linking | STL_LinkInit |
STL_LinkBack |
|
SCP initialization | STL_ScpInit |
Table 4-2
lists library routines in the
libinstall
shell script.
Table 4-2: Installation Library Routines
Purpose | Library Routine |
Cluster member identification | INST_GetMemberID |
Table 4-3
lists library routines in the
libswdb
shell script.
Table 4-3: Software Database Library Routines
Purpose | Library Routine |
Installed subsets | SWDB_FindInstalledSubsets |
3-digit version number | SWDB_FindInstalledVersions |
SWDB_FindLatestVersions |
|
Product name in subset control file (subset_id.ctrl) |
SWDB_GetProductName |
Subset installation status | SWDB_CompareStates
[Footnote 4]
|
SWDB_GetState
[Footnote 4] |
|
SWDB_IsCorrupt
[Footnote 4] |
|
SWDB_IsInstalled
[Footnote 4] |
|
Subset dependencies | SWDB_IsLocked
[Footnote 4] |
SWDB_ListLockingSubsets |
4.3.2 Setting Global Variables
You can call the
STL_ScpInit
routine to define these
variables and initialize them to their values for the current subset.
This
routine eliminates the need to hard code subset information in your subset
control program.
Note
Use the
STL_ScpInit
routine to initialize global variables at the beginning of allsetld
utility processing phases in your SCP except theM
phase. The control file is not read before theM
phase.All predefined global variable names begin with an underscore (
_
) for easier identification.
Table 4-4
lists global variables that
the subset control program can use to access information about the current
subset.
Table 4-4: STL_ScpInit Global Variables
Variable | Description |
_SUB |
Subset identifier, for example,
OATODB100 |
_DESC |
Subset description, for example,
Document Builder Tools |
_PCODE |
Product code, for example,
OAT |
_VCODE |
Version code, for example,
100 |
_PVCODE |
Concatenation of product code and version
code, for example,
OAT100 |
_PROD |
Product description, for example,
Orpheus Document Builder |
_ROOT |
The root directory of the installation |
_SMDB |
The location of the subset control files,
./usr/.smdb. |
_INV |
The inventory file, for example,
OATODB100.inv |
_CTRL |
The subset control file, for example,
OATODB100.ctrl |
_OPT |
The directory specifier
/opt/ |
_ORGEXT |
File extension for files saved by the
STL_LinkCreate
routine, set to
pre$_PVCODE
[Footnote 5]
|
_OOPS |
The NULL string, for dependency processing [Footnote 6] |
4.4 Working in a Cluster Environment
A cluster is a loosely coupled collection of servers that share storage and other resources that make applications and data highly available. A cluster consists of communications media, member systems, peripheral devices, and applications. The systems within a cluster communicate over a high-performance interconnect.
A TruCluster Server is a highly integrated synthesis of Tru64 UNIX
software,
AlphaServerTM
systems, and storage devices
that operate as a single virtual system.
The cluster file system (CFS) makes
the shared root,
usr
, and
var
file systems
visible and available to all cluster members.
Cluster members can share resources,
data storage, and clusterwide file systems under a single security and management
domain, yet they can boot or shut down independently without disrupting the
cluster's services to clients.
TruCluster Server includes a cluster alias for the Internet protocol suite (TCP/IP) so that a cluster appears as a single system to its network clients and peers.
For more information about clusters, see the TruCluster Server documentation set.
Note
This manual uses the term current member to mean the cluster member where an operation is taking place. This is not necessarily the cluster member where that operation was invoked.
When you create your subset control programs, consider the following restrictions so that your SCP tasks do not cause operational problems:
Any
setld
utility phase of your SCP must
be able to run more than once without causing operational problems.
This does
not mean that you must repeat the SCP tasks, but that multiple executions
will not cause the SCP to fail or corrupt existing files.
In a cluster, some
setld
utility phases
will run on each cluster member.
Any changes made by the SCP must first determine
if the change already has been made to that cluster member.
If so, the SCP
should not attempt to make the change again.
The SCP should never change the file type of an existing CDSL.
Do not try to change a CDSL to a file or directory. This would create a shared file where the cluster expects to find a link to a member-specific file and would cause cluster-wide problems.
The SCP should never change base operating system or cluster inventory.
The SCP should not decline a delete operation.
If a deconfiguration fails, report the error and continue the deletion, but do not exit with a nonzero status. The user must fix the problem after the software is removed.
Table 4-5
describes how
setld
utility phases behave when your SCP runs on a cluster.
Table 4-5: SCP Operations on a Cluster
setld Phase | Cluster Behavior |
all phases | All phases of
This does not mean that you must repeat the SCP tasks, but that multiple executions will not cause the SCP to fail. |
M |
Runs only on the cluster
member where you run the
setld
utility, which invokes the
SCP on that member. |
PRE_L |
Runs only once for the entire cluster.
If
you must run an operation on each cluster member, do it in the
|
POST_L |
Runs only once for the entire cluster.
If
you must run an operation on each cluster member, do it in the
|
C INSTALL |
Runs multiple times, once on each cluster member. If your SCP needs to access member-specific files, perform those operations here. |
C DELETE |
Runs multiple times, once on each cluster member. Always return a zero exit status from the
If the operation fails, report the error and continue processing. The user must fix the problem after the software is removed. [Footnote 8] |
PRE_D |
Runs only once for the entire cluster.
If
you must run an operation on each cluster member, do it in the
Always return a zero exit status from the
If the operation fails, report the error and continue processing. The user must fix the problem after the software is removed. [Footnote 8] |
POST_D |
Runs only once for the entire cluster.
If
you must run an operation on each cluster member, do it in the
Always return a zero exit status from the
|
V |
No cluster-specific restrictions. |
4.5 Working in a Dataless Environment
In a Dataless Management Services (DMS) environment, one computer acts as a server by storing the operating system software on its disk. Other computers, called clients, access this software across the Local Area Network (LAN) rather than from their local disks. See Sharing Software on a Local Area Network for more information about DMS.
The
setld
utility uses an alternate root directory
in a Dataless Management Services (DMS) environment.
To make your subset control
program DMS compliant, use dot-relative pathnames for file names and full
absolute pathnames starting from
root
( /
) for commands in your subset control program.
This ensures
that the proper command is executed when running on either the server or the
client in the dataless environment.
The following example shows the default path for SCP processing commands to be run from the server in a DMS environment:
/sbin:/usr/lbin:/usr/sbin:/usr/bin:.
A subset control program may need to perform differently in a dataless environment or disallow installation of the subset on such a system. If the product will be installed onto a DMS server, use relative pathnames in your SCP. The dataless environment root is the DMS area rather than the DMS server's root file system.
Caution
When running on a dataless client, the
/usr
area is not writable. You cannot install the product kit if any files reside in the/usr
directory. Make sure the subset control program does not attempt to write to any files located in the/usr
directory.
You can use the following routines to perform SCP processing in dataless environments:
4.6 Associating SCP Tasks with setld Utility Phases
The
setld
utility invokes the subset control program
during different phases of its processing.
The SCP can perform certain tasks
during any of these phases, such as creating or deleting a file or displaying
messages.
Other tasks that may be required, such as creating links, should
be performed only during specific phases.
Some tasks must take place during specific phases.
For example, creating
links between product files and the standard directory structure occurs during
the
POST_L
phase.
Figure 4-1
shows
setld
utility time lines for the
-l
,
-d
, and
-v
options.
Figure 4-1: Time Lines for setld Utility Phases
The actions taken by the
setld
utility are shown
above the time lines.
The SCP actions taken during each
setld
processing phase are shown below the time lines, along with any restrictions
when the SCP is run on a cluster.
When the
setld
utility enters a new phase, it first
sets the
ACT
environment variable to a corresponding value,
then invokes the subset control program.
The SCP determines the value of the
ACT
environment variable and any command line arguments to determine
the required action.
Note
Do not include wildcard characters in your subset control program's option-parsing routine. Write code only for the cases the subset control program actually handles. For example, the subset control programs in this chapter provide no code for several conditions under which they could be invoked, for example, the
V
phase.
The following sections describe the tasks that a subset control program
may perform in each
setld
processing phase:
Displaying the subset menu:
M
phase (Section 4.6.1)
Before loading the subset:
PRE_L
phase
(Section 4.6.2)
After loading the subset:
POST_L
phase
(Section 4.6.3)
Configuring after securing the subset:
C INSTALL
phase (Section 4.6.4)
Deconfiguring before deleting a subset:
C DELETE
phase (Section 4.6.5)
Before deleting a subset:
PRE_D
phase (Section 4.6.6)
After deleting a subset:
POST_D
phase (Section 4.6.7)
Verifying the subset:
V
phase (Section 4.6.8)
Caution
Any
setld
utility phase of your SCP must be able to run more than once without causing operational problems. This does not mean that you must repeat the SCP tasks, but that multiple executions will not cause the SCP to fail.
See
setld
(8)
and
stl_scp
(4)
for more information about the
setld
utility
and conventions for subset control programs.
4.6.1 Displaying the Subset Menu (M Phase)
Whenever it performs an operation, the
setld
utility
uses the
M
phase to determine if the subset should be included
in that operation.
Before displaying the menu,
setld
sets
the
ACT
environment variable to
M
and
calls the subset control program for each subset.
At this time, the subset
control program can determine whether to include its subset in the menu.
The
subset control program should return a value of 0 (zero) if the subset can
be included in the menu.
Note
In a cluster environment, the
M
phase runs only on the cluster member where thesetld
utility is invoked.
Example 4-1
shows a sample
setld
installation menu, listing the subsets available for installation.
Example 4-1: Sample setld Installation Menu
1) Kit One Name: Subset Description 2) Kit Two Name: Subset Description 3) Kit Three Name: Subset Description 4) Kit Four Name: Subset Description 5) ALL of the above 6) CANCEL selections and redisplay menus 7) EXIT without installing any subsets Enter your choices or press RETURN to redisplay menus. Choices (for example, 1 2 4-6):
When it calls the subset control program during this phase, the
setld
utility passes one argument, which can have one of two values:
The
-l
argument indicates that the
operation is a subset load.
The
-x
argument is reserved for extraction
of the subset into a RIS server's product area.
When
setld
extracts a subset into a RIS server's
product area, the server also executes the subset control program to make
use of the program's code for the
M
phase of installation.
You should code the
M
phase to detect the difference between
extraction of the subset into a RIS area and loading of the subset for use
of its contents.
To make this determination, determine the value of the
$1
command argument (either
-x
for RIS
extraction or
-l
for loading).
For RIS extraction,
the subset control program should take no action during the
M
phase.
When loading subsets, the SCP should perform a
machine
test.
The following Bourne shell example illustrates one way to code the
M
phase.
In
Example 4-2, the subset control
program is determining the type of processor on which it is running.
In this
example, there is no special code for the RIS extract case.
Example 4-2: Sample Test for Alpha Processor During M Phase
# # The ACT variable is set by setld and determines which # phase of the SCP should be executed. # case $ACT in # # This is the menu phase of the SCP # M) # # Setld invokes the M phase with an argument and if # the argument is "-l" it means that a software load # is occurring. # case $1 in -l) # # Examine the machine architecture to be sure # that this software is being installed on an # alpha machine. If it is not, exit with an # error status so that setld will not display # this subset on the menu of subsets to load. # ARCH=`./bin/machine` [ "$ARCH" = alpha ] || exit 1 ;; esac ;;
.
.
.
In
Example 4-2, the SCP returns the following
codes to the
setld
utility:
0
- display the subset in the menu
1
- do not display the subset in the menu
Note
Installation for a dataless client uses the client's local copy of the
machine
shell script even though the installation is performed in a DMS area on the server. See Section 4.5 and Sharing Software on a Local Area Network for more information about DMS.
4.6.2 Before Loading the Subset (PRE_L Phase)
After presenting the menu and before loading the subset, the
setld
utility sets the
ACT
environment variable
to
PRE_L
and calls the subset control program.
At this
time, the subset control program can take any action required to prepare the
system for subset installation, such as protecting existing files.
Note
In a cluster environment, the
PRE_L
phase is run only once for the whole cluster. If you must run member-specific operations when your subset is loaded, include the code in theC INSTALL
phase.Do not decline software loading because of one cluster member.
Use the
DEPS
field in the subset control file (subset_id.ctrl
) for subset dependency processing.
If you overwrite base operating system files, you may encounter the following problems:
Your product can be corrupted during an Update Installation of the operating system. The Update Installation will overwrite any file that is on the system with the version of the file shipped with the operating system.
An Update Installation may not complete successfully if you overwrite a base operating system file. This can make the system unusable.
Your product may have to be removed from the system to complete an Update Installation. Your product would have to be reinstalled after the Update Installation is completed.
Removing your product corrupts the operating system.
If your subset control program is designed to overwrite existing files,
it first should make a backup copy of the original file during the
PRE_L
phase and restore the copy in the
POST_D
phase described in
Section 4.6.7.
In
Example 4-3, the subset control program
examines a list of files to be backed up if they already exist on the system.
If it finds any, it creates a backup copy with an extension of
.OLD
.
Example 4-3: Sample Backup of Existing Files During PRE_L Phase
.
.
.
# # Here is a list of files to back up if found on # the installed system. # BACKUP_FILES="\ ./usr/var/opt/$_PVCODE/templates/odb_template \ [1] ./usr/var/opt/$_PVCODE/log_files/odb_log" [1]
.
.
.
# # The ACT variable is set by setld and determines which # phase of the SCP should be executed. # case $ACT in
.
.
.
# # This is the pre-load phase of the SCP # PRE_L) # # Loop through the list of backup files and create # backup copies for any file that is found on the # system. # for FILE in $BACKUP_FILES do # # If the file to be backed up exists, create # a backup copy with a .OLD extension. # if [ -f $FILE -a ! -f $FILE.OLD ] then cp $FILE $FILE.OLD [2] fi done ;;
.
.
.
The
STL_ScpInit
routine sets the value of the
$_PVCODE
global variable
to
OAT100
.
Using this variable allows the SCP to be used
for the next version of the product,
OAT200
, without changing
the pathnames.
[Return to example]
A backup copy is made if the specified
file exists and if a backup copy does not already exist.
This will be restored
in the
POST_D
phase.
[Return to example]
In
Example 4-3, the SCP returns the following
codes to the
setld
utility:
0
- load the subset
1
- do not load the subset
4.6.3 After Loading the Subset (POST_L Phase)
After loading the subset, the
setld
utility sets
the
ACT
environment variable to
POST_L
and calls the subset control program for each subset.
At this time the subset
control program can make any modifications required to subset files that usually
are protected from modification when the installation is complete.
The subset
control program should
create backward
links
at this time.
Note
In a cluster environment, the
POST_L
phase is run only once for the whole cluster. If you must run member-specific operations when your subset is loaded, include the code in theC INSTALL
phase.Do not decline software configuration because of one cluster member.
Sometimes you may need
to create links within your product-specific directories that refer
to files in the standard hierarchy.
Such
backward links
must be created carefully because the layered product
directories themselves can be symbolic links.
This means that you cannot rely
on knowing in advance the correct number of directory levels ( ../
) to include when you create your backward links.
For
example,
/var
is frequently a link to
/usr/var
.
When a kit is installed on a Network File System (NFS) server, the SCP
should make the backward links in the server's kit area.
When the server's
kit area is exported to clients, the links are already in place and you do
not need to create any backward links in the client area.
This is done so
that installation on an NFS client cannot overwrite any existing backward
links in the server's kit areas.
You do not run the subset control program
on an NFS client.
Your subset control program should create and remove backward
links in the
POST_L
and
PRE_D
phases,
respectively.
Caution
NFS clients importing products with backward links must have directory hierarchies that exactly match those on the server. Otherwise, the backward links fail.
Use the
STL_LinkInit
and
STL_LinkBack
routines to create backward links as follows, and use the
rm
command to remove them:
POST_L
phase to establish internal
variables for the
STL_LinkBack
routine.
Before you use
STL_LinkBack
to create a link, you must execute
STL_LinkInit
once.
This routine has no arguments and returns no status.
STL_LinkBack
link_file file_path link_path
/usr/opt
or
/usr/var/opt
) to a directory within
the standard UNIX directory structure.
In this example,
link_file
is the file to link,
file_path
is
the dot-relative path of the directory where the file actually resides, and
link_path
is the dot-relative path of the directory where you
should place the link.
You can use
STL_LinkBack
repeatedly
to create as many links as required.
This routine returns no status.
The SCP in
Example 4-4
uses
STL_LinkBack
in the
POST_L
phase to create a link named
/opt/OAT100/sbin/ls
.
This link refers to the real file
/sbin/ls
.
The SCP removes the link in the
PRE_D
phase.
Example 4-4: Sample Backward Link Creation During POST_L Phase
case $ACT in
.
.
.
# # This is the post-load phase of the SCP # POST_L) # # Initializes the variables so that STL_LinkBack can be executed # STL_LinkInit # # Create a symbolic link in the ./opt/$_PVCODE/sbin # directory that points to the ./sbin/ls file. # STL_LinkBack ls ./sbin ./opt/$_PVCODE/sbin [1] ;; PRE_D) # # Remove the links created in the POST_L phase # rm -f ./opt/$_PVCODE/sbin/ls [2] ;;
.
.
.
The
STL_LinkBack
routine creates a backward link in the product-specific area, as described
in the comment above the code.
The
STL_ScpInit
routine
sets the value of the
$_PVCODE
global variable to
OAT100
.
Using this variable allows the SCP to be used for the next
version of the product,
OAT200
, without changing the pathnames.
[Return to example]
The SCP uses the
rm
command to remove the links created in the
POST_L
phase.
[Return to example]
setld
utility:
0
- continue subset configuration
1
- terminate subset configuration; leave the subset
corrupt
The
setld
utility creates an empty
subsetID.lk
lock file when it loads a subset.
After
successful installation, that subset is then available for dependency processing
and locking is performed when other subsets are installed later.
A subset's
lock file can then contain any number of records, each naming a single dependent
subset.
For example, the ODB kit requires that some version of the Orpheus Document
Builder base product must be installed for the ODB product to work properly.
Suppose that the
OATBASE200
subset is present.
When the
setld
utility installs the
OATODBTEMPS100
subset
from the ODB kit, it inserts a record that contains the subset identifier
OATODBTEMPS100
into the
OATBASE200.lk
file.
When
the system administrator uses the
setld
utility to remove
the
OATBASE200
subset, the
setld
utility
examines
OATBASE200.lk
and finds a record that indicates
that
OATODBTEMPS100
depends on
OATBASE200
,
displays a warning message, and requires confirmation that the user really
intends to remove the
OATBASE200
subset.
If the administrator removes the
OATODBTEMPS100
subset,
the
setld
utility removes the corresponding record from
the
OATBASE200.lk
file.
Thereafter, the administrator can
remove the
OATBASE200
subset without causing a dependency
warning.
The SCP uses the
DEPS
field in the subset control
file (subset-id.ctrl
) to perform
dependency locking.
4.6.4 After Securing the Subset (C INSTALL Phase)
After securing the subset, the
setld
utility sets
the
ACT
environment variable to
C
(configuration)
and calls the subset control program for each subset, passing
INSTALL
as an argument.
At this time, the subset control program can perform
any configuration operations required for product-specific tailoring.
For
example, a kernel kit can statically or dynamically configure a device driver
at this point.
The
setld
utility enters the
C INSTALL
phase when
setld
is invoked with the
-l
(load) option.
Note
In a cluster environment, the
C INSTALL
phase runs multiple times, once on each cluster member. You must be able to run any SCP operations in theC INSTALL
phase more than once without causing a problem.If your SCP needs to access member-specific files, perform those operations during the
C INSTALL
phase.
The subset control program cannot create a layered product's symbolic
links during the
C INSTALL
phase.
Example 4-5
shows the
C INSTALL
portion of the SCP that issues a message upon successful subset installation.
Example 4-5: Sample Message Output During C INSTALL Phase
# The ACT variable is set by setld and determines which # phase of the SCP should be executed. # case $ACT in
.
.
.
# # This is the configuration phase of the SCP # C) # # Setld invokes the C phase with an argument that is # either INSTALL or DELETE. The INSTALL argument is # used on a setld load, while the DELETE argument is # used on a setld delete. # case $1 in INSTALL) [1] # # Output a message letting the user know # that they should check the odb.conf file # before using the product. # echo " The installation of the $_DESC ($_SUB) [2] software subset is complete. Please check the /opt/$_PVCODE/odb.conf file before [3] using the $_DESC product." [2] ;;
.
.
.
esac ;;
.
.
.
During the
C
phase, the SCP determines if the first argument passed by the
setld
utility has the value of
INSTALL
.
If so, the
program displays a message indicating that the installation is complete.
[Return to example]
The
STL_ScpInit
routine sets the value of the
$_DESC
global variable to
Orpheus Document Builder
and the
$_SUB
global
variable to
OATODB100
, resulting in the following message:
The installation of the Orpheus Document Builder (OATODB100) software subset is complete. Please check the /opt/OAT100/odb.conf file before using the Orpheus Document Builder product."
The
STL_ScpInit
routine sets the value of the
$_PVCODE
global variable
to
OAT100
.
Using this variable allows the SCP to be used
for the next version of the product,
OAT200
, without changing
the pathnames.
[Return to example]
In
Example 4-5, the SCP returns the following
codes to the
setld
utility:
0
- successful load and configure
1
- unsuccessful load and configure; leave the
subset corrupt
4.6.5 Before Deleting a Subset (C DELETE Phase)
When the user invokes the
setld
utility with the
-d
option, the utility sets the
ACT
environment
variable to
C
and calls the subset control program for
each subset, passing
DELETE
as an argument.
At this time,
the subset control program can make configuration modifications to remove
evidence of the subset's existence from the system.
For example, a kernel
kit would deconfigure a statically or dynamically configured driver during
this phase.
The
C DELETE
phase should reverse any changes
made during the
C INSTALL
phase.
Note
In a cluster environment, the
C DELETE
phase runs multiple times, once on each cluster member. You must be able to run any SCP operations in theC DELETE
phase more than once without causing a problem.The SCP always should return a zero exit status in the
C DELETE
phase. A nonzero return status tells thesetld
utility not to delete the software, but if the SCP has run theC DELETE
phase on other cluster members the software already may be marked as corrupt.If an operation fails, report the error and continue processing. The user must fix the problem after the software is removed.
The subset control program cannot remove a layered product's links during
the
C DELETE
phase.
Example 4-6
shows the
C DELETE
portion of the SCP that would reverse any changes made during the
C INSTALL
phase.
Example 4-6: Sample C DELETE Phase
# # The ACT variable is set by setld and determines which # phase of the SCP should be executed. # case $ACT in
.
.
.
# # This is the configuration phase of the SCP # C) # # Setld invokes the C phase with an argument that is # either INSTALL or DELETE. The INSTALL argument is # used on a setld load, while the DELETE argument is # used on a setld delete. # case $1 in INSTALL) # # Output a message letting the user know # that they should check the odb.conf file # before using the product. # echo " The installation of the $_DESC ($_SUB) software subset is complete. Please check the /opt/$_PVCODE/odb.conf file before using the $_DESC product." ;; DELETE) ;; [1] esac ;;
.
.
.
This phase should reverse any
changes made during the
C INSTALL
phase.
Since no changes
were made in
Example 4-5, no action is taken in the
C DELETE
phase.
[Return to example]
setld
utility:
0
- continue with the deletion
1
- terminate the deletion
4.6.6 Before Deleting a Subset (PRE_D Phase)
When the user invokes the
setld
utility with the
-d
option, the utility sets the
ACT
environment
variable to
PRE_D
and calls the subset control program
for each subset.
At this time, the subset control program can reverse modifications
made during the
POST_L
phase of installation, such as removing
links.
Note
In a cluster environment, the
PRE_D
phase runs only once for the entire cluster. If you must run member-specific operations when your subset is deleted, include the code in theC DELETE
phase.The SCP always should return a zero exit status in the
PRE_D
phase. A nonzero return status tells thesetld
utility not to delete the software, but since the SCP has run theC DELETE
phase the software is already marked as corrupt.If an operation fails, report the error and continue processing. The user must fix the problem after the software is removed.
The SCP uses the
DEPS
field in the subset control
file (subset-id.ctrl
) to perform
dependency unlocking.
In
Example 4-4, the SCP used
STL_LinkBack
in the
POST_L
phase to create the
/opt/OAT100/sbin/ls
link, referring to the
/sbin/ls
file.
Example 4-7
shows the SCP removing this link in the
PRE_D
phase.
Example 4-7: Sample PRE_D Phase Reversal of POST_L Phase Actions
case $ACT in
.
.
.
# # This is the pre-deletion phase of the SCP # PRE_D) # # Remove the links created in the POST_L phase # rm -f ./opt/$_PVCODE/sbin/ls [1] ;;
.
.
.
The SCP uses the
rm
command to remove the links created in the
POST_L
phase.
[Return to example]
setld
utility:
0
- continue with the deletion
1
- terminate the deletion
4.6.7 After Deleting a Subset (POST_D Phase)
During the
POST_D
phase, after deleting a subset,
the
setld
utility sets the
ACT
environment
variable to
POST_D
and calls the subset control program
for each subset.
At this time the subset control program can reverse any modifications
made during the
PRE_L
phase of installation.
Note
In a cluster environment, the
POST_D
phase is run only once for the whole cluster. If you must run member-specific operations when your subset is deleted, include the code in theC DELETE
phase.The SCP always should return a zero exit status in the
POST_D
phase. A nonzero return status tells thesetld
utility not to delete the software, but the subset already has been removed. This causes cluster corruption.If an operation fails, report the error and continue processing. The user must fix the problem after the software is removed.
In
Example 4-8, the subset control program examines
a list of files to be backed up if they already exist on the system.
If it
finds any, it restores the backup copy.
Example 4-8: Sample File Restoration During POST_D Phase
.
.
.
# # Here is a list of files to back up if found on the installed system. # BACKUP_FILES="\ ./usr/var/opt/$_PVCODE/templates/odb_template \ [1] ./usr/var/opt/$_PVCODE/log_files/odb_log" # # The ACT variable is set by setld and determines which # phase of the SCP should be executed. # case $ACT in
.
.
.
# # This is the post-deletion phase of the SCP # POST_D) # # Restore the backup copies created during the PRE_L phase # for FILE in $BACKUP_FILES do [ -f $FILE.OLD ] && mv $FILE.OLD $FILE [2] done ;;
.
.
.
esac
The
STL_ScpInit
routine sets the value of the
$_PVCODE
global variable
to
OAT100
.
Using this variable allows the SCP to be used
for the next version of the product,
OAT200
, without changing
the pathnames.
[Return to example]
Restores any files backed up in
the
PRE_L
phase, as shown in
Example 4-3.
[Return to example]
In
Example 4-8, the SCP returns the following codes
to the
setld
utility:
0
- deletion was successful; no errors
1
- errors during deletion, software was removed
4.6.8 Verifying the Subset (V Phase)
When the user invokes the
setld
utility with the
-v
option, the utility sets the
ACT
environment
variable to
V
and calls the subset control program for
the subset.
Any
V
phase processing included in the subset
control program is executed at this time.
The
setld
utility determines the existence of the
installed subset and if the subset exists, the
setld
utility
verifies the size and checksum information for each file in the subset.
The
setld
utility does not execute subset control program
V
phase processing during the installation process.
4.7 Determing Subset Installation Status
Subset installation status can drive conditional actions in subset control programs, and accurately determining this status is especially important for recovery processing.
The following topics are discussed in this section:
How the current version of the operating system defines installation and determines subset status (Section 4.7.1)
Internal installation states and how they reflect software subset status (Section 4.7.2)
Using subset installation status library routines in your SCP (Section 4.7.3)
4.7.1 Defining Installation and Subset Status
In the current operating system environment that includes TruCluster Server, software installation status is defined as follows:
A subset is loaded when its software is copied onto the system
A subset is installed after it is loaded and its SCP has completed successfully
A software subset can be loaded on one cluster member, corrupt on another,
and fully installed and configured on a third.
The
subset.lk
and
subset.dw
files are no longer sufficient to describe software subset installation
status.
The
setld
utility generates a r,
subset.sts
, for each subset.
This file describes
the subset's current installation state and reflects the success or failure
of specific phases of the installation or deletion process.
The
setld
utility removes the subset status file when it deletes the
software subset.
Each
/usr/.smdb./
subset.sts
file is a context-dependent symbolic link (CDSL) to the corresponding
/usr/cluster/members/{memb}/.smdb./
subset.sts
file.
The
subset.lk
file still
exists but now is used only to list dependent subsets.
4.7.2 Understanding Internal Codes for Installation States
Subset installation status corresponds to
setld
utility
processing phases as shown in
Figure 4-1.
Internal
states are provided to describe software subset installation status.
Caution
Although subset installation status is reflected in more than one place, your SCP must use these internal states to determine subset installation status. Do not use the contents of the subset status file or the output of the
setld -i
command.
Table 4-6
describes these internal code states:
Table 4-6: Software Subset Installation Status
Internal Code State | Description |
_not_installed |
The software is not on the system. Either the subset was not installed or it was deleted successfully. |
_deleting |
The
setld
utility is in the process
of deleting the software.
The
setld -d
process has not
completed or failed to delete the subset. |
_pre_load_failed |
The
setld
utility failed in the
PRE_L phase.
Although the software did not load onto the system, some system
changes may have been made. |
_pre_load_completed |
The
setld
utility finished the PRE_L
phase and the software is ready to load onto the system. |
_verify_failed |
The software is loaded onto the system, but one or more of the files failed the verification process and the software is not installed and cannot be used. The verification process compares the size and checksum of the file on the system against the inventory record. If either value does not match, the file fails verification. |
_verify_completed
[Footnote 9]
|
The software is loaded onto the system; all of the subset files are present and verified. The software is not yet installed on the system, as the POST_L and C INSTALL phases must run and protected system files must be moved into place. |
_post_load_failed |
The software is loaded onto the system but the
setld
utility failed in the POST_L phase.
The subset files are present
but the software is not installed. |
_post_load_completed |
The software is loaded onto the system and the
setld
utility completed the POST_L phase.
The subset files are present
and the software is ready to be configured in the C INSTALL phase. |
_populate_failed |
The software is loaded onto the cluster, the
setld
utility completed the POST_L phase, but the copying of member-specific
files to the current cluster member failed or did not complete. |
_populate_completed
|
The software is loaded onto the cluster, the
setld
utility completed the POST_L phase, and all member-specific
files were copied to the current cluster member.
The software is ready to
be configured in the C INSTALL phase on the current cluster member.
|
_c_install_failed |
The software is loaded onto the system but the
setld
utility failed in the C INSTALL phase.
The subset files are
present but the software is not configured or installed. |
_c_install_completed |
The
setld
utility completed the C
INSTALL phase and the software is installed on the system.
There are no other
installation steps required by the
setld
utility, although
the software may require additional setup before use. |
any other value | The subset status file is corrupted and an unsupported string cannot be mapped to a valid state. This is a serious condition and may require that you remove and reinstall the software. |
Caution
Subset control programs (SCPs) cannot use the
subset.lk
andsubset.dw
files to determine if a subset is installed.
The distinction between whether a subset is loaded or installed is important
because existing SCPs can fail if they only determine the existence of
subset.lk
files.
For example:
If your software is dependent upon another subset being installed,
confirm that the other subset's installation status is
_c_install_completed
.
If your software requires that another subset's files are
present on the system, you only need to confirm that the other subset's installation
status is
_verify_completed
.
See Section 4.7.3 for information about using subset installation status library routines to determine subset installation status.
See
stl_sts
(4)
for more information about subset status files.
See
setld
(8)
for more information about how the
setld
utility processes and displays software subsets.
4.7.3 Using Subset Installation Status Library Routines
Library routines for determining subset installation status are located
in the
/usr/share/lib/shell/libswdb
shell script.
These
routines are applicable to both single systems and clusters.
Caution
Do not use subset status file values or output from the
setld -i
command to determine software subset installation status. Although these values correspond to the internal code state reflecting subset status, they are not identical and are subject to change. Use the supplied library routines to determine subset installation status in your SCPs.
To use these library routines in your subset control program, you first must source the library shell script as in the following example:
SHELL_LIB=${SHELL_LIB:-/usr/share/lib/shell} . $SHELL_LIB/libswdb
The
/usr/share/lib/shell/libswdb
shell script includes
the following library routines:
SWDB_IsInstalled
subset
Returns
0
if
subset
is installed (in the
_c_install_completed
state) on the
current member, otherwise returns
1
.
Example:
SWDB_IsInstalled OSFBASE520
SWDB_IsLocked
subset
Returns
0
if
subset
is installed and required by another subset, otherwise returns
1
, indicating either that
subset
is not
installed or that
subset
is installed but that
no other subset is dependent upon it.
Example:
SWDB_IsLocked OSFBASE520
SWDB_IsCorrupt
subset
Returns
0
if
subset
either failed to load or if the SCP failed in one of the
setld
utility phases, otherwise returns
1
.
Example:
SWDB_IsCorrupt OSFBASE520
SWDB_GetState
subset
Returns the internal code state reflecting the installation
status of
subset.
Example:
STATE=`SWDB_GetState OSFBASE520`
This example retrieves the current state of the
OSFBASE520
subset and stores the value in the
STATE
variable.
See
Table 4-6
for descriptions of subset installation status
internal code states.
SWDB_CompareStates
state1
state2
Returns
0
if
state1
is before
state2
in the
setld
utility processing sequence,
1
if
state1
is the same as
state2
, or
2
if
state1
is after
state2
.
Use the results of
SWDB_GetState
as one of the arguments
to the
SWDB_CompareStates
library routine to compare a
subset's internal code state with a fixed code state.
This lets you know if
the subset status has reached a particular code state and reflects the progress
of the subset installation.
This routine is useful in determining where to
resume processing during a recovery procedure.
Example:
STATE=`SWDB_GetState OSFBASE520` SWDB_CompareStates $STATE _verify_completed
This example determines if the
OSFBASE520
subset has reached the
_verify_completed
state on the current
member.
The following list shows samples of old SCP code along with new code that uses the new library routines to determine subset installation status.
In the first case, the SCP must determine if the
OSFBASE520
subset is installed.
Old SCP code determines if the
OSFBASE520.lk
file exists and is a regular file.
For example:
[ -f OSFBASE520.lk ] && { ... code to execute if software is installed... }
New SCP code uses the
SWDB_IsInstalled
routine and looks for a return code of
0
.
For example:
SWDB_IsInstalled OSFBASE520 [ "$?" = "0" ] && { ... code to execute if software is installed... }
In the second case, the SCP must determine if the
OSFBASE520
subset is corrupt.
Old SCP code determines if the
OSFBASE520.dw
file exists.
For example:
[ -f OSFBASE520.dw ] && { ... code to execute if software is corrupt... }
New SCP code uses the
SWDB_IsCorrupt
routine
and looks for a return code of
0
.
For example:
SWDB_IsCorrupt OSFBASE520 [ "$?" = "0" ] && { ... code to execute if software is corrupt... }
In the third case, the SCP must determine if the software is loaded regardless of whether it is installed.
This case did not exist in previous versions of the operating system.
New SCP code uses the
SWDB_GetState
and
SWDB_CompareState
routines and looks for a return code that is not
zero.
For example:
STATE=`SWDB_GetState OSFBASE520` SWDB_CompareStates $STATE _verify_loaded [ "$?" != "0" ] && { ... code to execute if software is loaded ... }
Depending on the tests performed, your subset control program could decide to stop the installation or deletion of its subset. For example, if it finds a later version of the product already installed, the subset control program can stop the process.
To stop the installation or deletion of the subset, the subset control
program must return a nonzero status to the
setld
utility
when it exits the phase.
If the subset control program returns a status of
0 (zero), the
setld
utility continues, assuming that the
SCP is satisfied.
4.9 Creating SCPs for Different Product Kit Types
This section provides examples of subset control programs for each of the different product kit types. The following topics are discussed:
Creating SCPs for user product kits (Section 4.9.1)
Creating SCPs for kernel product kits (Section 4.9.2)
4.9.1 Creating User Product Kit SCPs
User product kits do not require subset control programs. You may need to provide one if your user product requires special installation tasks.
Example 4-9
shows a subset control program for the
ODB user product, illustrating the types of operations that can be performed
during different
setld
phases and illustrating one method
of using the value of the
ACT
environment variable to determine
what actions to perform.
Example 4-9: Sample ODB User Product SCP
#!/sbin/sh # # Load all of the standard SCP library routines # SHELL_LIB=${SHELL_LIB:-/usr/share/lib/shell} . $SHELL_LIB/libswdb # # Initialize the global variables, except in the M phase # if [ "$ACT" != "M" ] then STL_ScpInit fi # # Here is a list of files to back up if found on # the installed system. # BACKUP_FILES="\ ./usr/var/opt/$_PVCODE/templates/odb_template \ ./usr/var/opt/$_PVCODE/log_files/odb_log" # # The ACT variable is set by setld and determines which # phase of the SCP should be executed. # case $ACT in # # This is the menu phase of the SCP # M) # # Setld invokes the M phase with an argument and if # the argument is "-l" it means that a software load # is occurring. # case $1 in -l) # # Examine the machine architecture to be sure # that this software is being installed on an # alpha machine. If it is not, exit with an # error status so that setld will not display # this subset on the menu of subsets to load. # ARCH=`./bin/machine` [ "$ARCH" = alpha ] || exit 1 ;; esac ;; PRE_L) # # Loop through the list of backup files and create # backup copies for any file that is found on the # system. # for FILE in $BACKUP_FILES do # # If the file to be backed up exists, create # a backup copy with a .OLD extension. # if [ -f $FILE ] then cp $FILE $FILE.OLD fi done ;; POST_L) # # Initializes the variables so that the STL_LinkBack # routine can be executed # STL_LinkInit # # Create a symbolic link in the ./opt/$_PVCODE/sbin # directory that points to the ./sbin/ls file. # STL_LinkBack ls ./sbin ./opt/$_PVCODE/sbin ;; PRE_D) # # Remove the links created in the POST_L phase # rm -f ./opt/$_PVCODE/sbin/ls ;; POST_D) # # Restore the backup copies created during the PRE_L phase # for FILE in $BACKUP_FILES do [ -f $FILE.OLD ] && mv $FILE.OLD $FILE done ;; C) # # Setld invokes the C phase with an argument that is # either INSTALL or DELETE. The INSTALL argument is # used on a setld load, while the DELETE argument is # used on a setld delete. # case $1 in INSTALL) # # Output a message letting the user know # that they should check the odb.conf file # before using the product. # echo " The installation of the $_DESC ($_SUB) software subset is complete. Please check the /opt/$_PVCODE/odb.conf file before using the $_DESC product." ;; DELETE) ;; esac ;; esac exit 0
4.9.2 Creating Kernel Product Kit SCPs
In addition to the optional processing described in Section 4.6, a subset control program for a kernel product such as a device driver also must configure the driver into the kernel. When building subset control programs for a kernel product, you can choose one of the following configuration strategies:
Write one subset control program for a kit that contains the software subset associated with the single binary module for a statically configured driver.
Write one subset control program for a kit that contains the software subset associated with the single binary module for a dynamically configured driver.
Write one subset control program for a kit that contains the software subsets associated with the device driver that can be statically or dynamically configured.
Example 4-10
shows the subset control program for the
single binary module associated with the
odb_kernel
driver.
The user can choose to configure this single binary module into the kernel
either statically or dynamically.
The subset control program runs the
doconfig
utility to configure the driver into the kernel.
Example 4-10: Sample ODB Kernel Product SCP
#!/sbin/sh # # Load all of the standard SCP library routines # SHELL_LIB=${SHELL_LIB:-/usr/share/lib/shell} . $SHELL_LIB/libswdb # Load the standard Error library routines # (location of the Error routine) # . $SHELL_LIB/Error # # Load the standard String library routines # (location of the ToUpper routine) # . $SHELL_LIB/Strings # # This routine rebuilds the static kernel # Rebuild_Static_Kernel() { HNAME=`/sbin/hostname -s` HOSTNAME=`ToUpper $HNAME` if doconfig -c $HOSTNAME then echo "\nThe /sys/${HOSTNAME}/vmunix kernel has been" echo "moved to /vmunix and the changes will take effect" echo "the next time the system is rebooted." return 0 else Error " An error occurred while building the static kernel." return 1 fi } KERNEL=/cluster/members/{memb}/boot_partition/vmunix # # Initialize the global variables, except in M phase # if [ "$ACT" != "M" ] then STL_ScpInit fi # # The ACT variable is set by setld and determines which # phase of the SCP should be executed. # case $ACT in C) # # The kreg database file where all of the kernel # layered products are registered. # KREGFILE=./usr/sys/conf/.product.list case $1 in INSTALL) # # Merge the graphics support into the existing # /etc/sysconfigtab file # sysconfigdb -m -f ./opt/$_PVCODE/etc/sysconfigtab odb_graphics echo "*** $_DESC Product Installation Menu ***\n" echo "1. Statically configure the graphics support" echo "2. Dynamically configure the graphics support" echo "\nType the number of your choice []: \c" read answer case ${answer} in 1) # # Determine if the product is already registered # with the kreg database, and if it is, skip # registering it. # grep -q $_SUB $KREGFILE if [ "$?" != "0" ] then # # Register the product with the # kernel using kreg # /sbin/kreg -l $_PCODE $_SUB \ ./opt/$_PVCODE/sys/BINARY fi # # Rebuild the static kernel # Rebuild_Static_Kernel # # Successful rebuild, so back up the existing # kernel and move the new one into place. # if [ "$?" = "0" ] then # # Make a backup copy of the kernel # as it existed prior to installing # this subset. Since a subset can # be installed more than once (due to # load/configuration failures or even # because the user removed files) make # sure that the backup does not already # exist. # if [ ! -f $KERNEL.pre_${_SUB) then mv $KERNEL $KERNEL/pre_${_SUB) fi # # Move the new kernel into place # mv /sys/${HOSTNAME}/vmunix /vmunix # # Place a marker on the system so that # upon subset removal the SCP can # determine if it needs to remove a # static or dynamic configuration. # touch ./opt/$_PVCODE/sys/BINARY/odb_graphics_static fi ;; 2) # # Dynamically load the odb_graphics subsystem # into the kernel # sysconfig -c odb_graphics ;; esac ;; DELETE) # # If the marker is present then the kernel option # was added statically. # if [ -f ./opt/$_PVCODE/sys/BINARY/odb_graphics_static ] then # # Clean-up the marker # rm -f ./opt/$_PVCODE/sys/BINARY/odb_graphics_static # # Deregister the product using kreg # /sbin/kreg -d $_SUB # # Rebuild the static kernel # Rebuild_Static_Kernel # # Successful rebuild, remove the old backup # copy that was created when we installed. # if [ "$?" = "0" ] then mv /sys/${HOSTNAME}/vmunix /vmunix rm -f $KERNEL.pre_${_SUB} fi else # # Unload the dynamic kernel module # sysconfig -u odb_graphics fi # # Remove the entry from the /etc/sysconfigtab file # sysconfigdb -d odb_graphics ;; esac ;; esac exit 0