Solaris 8 Advanced Installation Guide

Chapter 8 Creating Custom Rule and Probe Keywords

This chapter provides information and procedures for creating your own custom rule and probe keywords.


Note -

The name of this product is Solaris 8, but code and path or package path names might appear as Solaris_2.8 or SunOS_5.8. Always follow the code or path as it is written.


Probe Keywords

What Is a Probe Keyword?

To understand what a probe keyword is, you first need to recall what a rule keyword is: a predefined lexical unit or word that describes a general system attribute, such as host name (hostname) or memory size (memsize). Rule keywords and their associated values enable you to match a system that has the same attribute to a profile, which defines how the Solaris software is to be installed on each system in the group.

Custom JumpStart environment variables, which you use in begin and finish scripts, are set on demand. For example, information about which operating system is already installed on a system is only available (in SI_INSTALLED) after the installed rule keyword is used.

In some situations, however, you might need to extract this same information in a begin or finish script for a purpose other than to match a system and run a profile. Probe keywords provide the solution. They extract this same attribute information without your having to set up a matching condition and run a profile.

Probe Keywords and Values

Table 8-1 describes each rule keyword and its equivalent probe keyword.


Note -

Always place probe keywords at or near the beginning of the rules file.


Table 8-1 Descriptions of Probe Keywords

Rule Keyword 

Equivalent Probe Keyword 

Description of Probe Keyword 

any

None  

  

arch

arch

Determines the kernel architecture (i386 or SPARC) and sets SI_ARCH.

disksize

disks

Returns the size of a system's disks (in Mbytes) in kernel probe order (c0t3d0s0, c0t3d0s1, c0t4d0s0) and sets SI_DISKLIST, SI_DISKSIZES, SI_NUMDISKS, and SI_TOTALDISK.

domainname

domainname

Returns a system's NIS or NIS+ domain name or (if none) blank and sets SI_DOMAINNAME (this keyword actually returns the output of domainname(1M)).

hostaddress

hostaddress

Returns a system's IP address (the first address listed in the output of ifconfig(1M) -a that is not lo0) and sets SI_HOSTADDRESS.

hostname

hostname

Returns a system's host name (output from uname(1) -n) and sets SI_HOSTNAME.

installed

installed

Returns the version name, Solaris_2.x or Solaris_x, of the Solaris operating environment that is installed on a system and sets SI_ROOTDISK and SI_INSTALLED.

If JumpStart finds a Solaris release but is unable to determine the version, the version returned is SystemV.

karch

karch

Returns a system's platform group (i86pc, sun4m, and sun4u, for example) and sets SI_KARCH. Appendix A, Platform Names and Groups contains a list of platform names.

memsize

memsize

Returns the size of physical memory on a system (in Mbytes) and sets SI_MEMSIZE. 

model

model

Returns a system's platform name and sets SI_MODEL. Appendix A, Platform Names and Groups contains a list of platform names.

network

network

Returns a system's network number, which JumpStart determines by performing a logical AND between the system's IP address and the subnet mask (which are extracted from the first address listed in the output of ifconfig(1M) -a that is not lo0); also sets SI_NETWORK.

osname

osname

Returns the version and operating system name, Solaris_2.x or Solaris_x, of the Solaris operating environment that is found on a CD and sets SI_OSNAME.

If JumpStart finds a Solaris release but is unable to determine the version, the version returned is SystemV.

  

rootdisk

Returns the name and size (in Mbytes) of a system's root disk and sets SI_ROOTDISK.

totaldisk

totaldisk

Returns the total disk space on a system (in Mbytes) and sets SI_TOTALDISK. The total disk space includes all the operational disks attached to a system.

Creating a custom_probes File

If the rule and probe keywords described in Table 6-3 and Table 8-1 are not enough for your needs, you can define your own custom rule or probe keywords by creating a custom_probes file.

What Is a custom_probes File?

The custom_probes file, which must be located in the same JumpStart directory as the rules file, is a Bourne shell script that contains two types of functions.

Table 8-2 Types of Functions You Define in custom_probes

Type of Function 

Description 

Probe 

Gathers the information you want or does the actual work and sets a corresponding SI_ environment variable you define. Probe functions become probe keywords.

Comparison 

Calls a corresponding probe function, compares the output of the probe function, and returns 0 if the keyword matches or 1 if the keyword doesn't match. Comparison functions become rule keywords. 

Syntax of the custom_probes File

The custom_probes file can contain any valid Bourne shell command, variable, or algorithm.


Note -

You can define probe and comparison functions that require a single argument in the custom_probes file. When you subsequently use the corresponding custom probe keyword in the rules file, the argument after the keyword is interpreted (as $1).

When you subsequently use the corresponding custom rule keyword in the rules file, the argument is interpreted starting after the keyword and ending before the next && or begin script, whichever comes first.


The custom_probes file must:

To improve clarity and organization, define all probe functions first, at the top of the file, followed by all comparison functions.

Syntax of Function Names in custom_probes

The name of a probe function must begin with probe_. The name of a comparison function must begin with cmp_.

Functions that begin with probe_ define new probe keywords (the function probe_tcx defines the new probe keyword tcx, for example). Functions that begin with cmp_ define new rule keywords (cmp_tcx defines the new rule keyword tcx, for example).

Example of a custom_probes File

This custom_probes file contains a probe and comparison function that tests for the presence of a TCX graphics card.


Note -

You can find additional examples of probe and comparison functions in:


#!/bin/sh
# 
# custom_probe script to test for the presence of a TCX graphics card.
# 

# 
# PROBE FUNCTIONS
# 
probe_tcx() {
  SI_TCX=`modinfo | grep tcx | nawk '{print $6}'`
  export SI_TCX
}

# 
# COMPARISON FUNCTIONS
# 
cmp_tcx() {
  probe_tcx

  if [ "X${SI_TCX}" = "X${1}" ]; then
     return 0
  else
     return 1
  fi
}

Example of a Custom Probe Keyword Used in a rules File

This example rules file shows the use of the probe keyword defined in the preceding example (tcx). If a TCX graphics card is installed and found in a system, profile_tcx is run. Otherwise, profile is run.


Note -

Always place probe keywords at or near the beginning of the rules file to ensure that they are read and run before other rule keywords (that may rely on them).


probe tcx
tcx     tcx     -     profile_tcx     -
any     any     -     profile         -

To Create a custom_probes File

  1. Using a text editor of your choice, create a Bourne shell script text file named custom_probes.

  2. In the custom_probes text file, define the probe and comparison functions you want.


    Note -

    You can define probe and comparison functions that require arguments in the custom_probes file. When you subsequently use the corresponding custom probe keyword in the rules file, the arguments after the keyword are interpreted in sequence (as $1, $2, and so on).

    When you subsequently use the corresponding custom rule keyword in the rules file, the arguments are interpreted in sequence starting after the keyword and ending before the next && or begin script, whichever comes first.


  3. Save the custom_probes file in the JumpStart directory (next to the rules file).

    Ensure that root owns the rules file and that its permissions are set to 644.

Validating the custom_probes File

Before you can use a profile, rules, and custom_probes file, you must run the check script to validate that these files are set up correctly. If all profiles, rules, and probe and comparison functions are correctly set up, the rules.ok and custom_probes.ok files are created. Table 8-3 describes what the check script does.

Table 8-3 What Happens When You Use check

Stage 

Description 

check searches for a custom_probes file.

If the file exists, check creates the custom_probes.ok file from the custom_probes file, removes all comments and blank lines, retains all Bourne shell commands, variables, and algorithms, and adds the following comment line at the end:

# version=2 checksum=num


Note -

Ensure that root owns the custom_probes.ok file and that its permissions are set to 755.


Syntax of check

This is the syntax of the check script you use to test a custom_probes file:


$ ./check [[-p path -r file_name]]

Table 8-4 Description of check Script Arguments

Argument 

Description 

-p path

Validates the custom_probes file by using the check script from the Solaris 8 Software 1 of 2 CD image for your platform, instead of the check script from the system you are using. path is the image on a local disk or a mounted Solaris 8 Software 1 of 2 CD.

Use this option to run the most recent version of check if your system is running a previous version of Solaris.

-r file_name

Specifies a file name other than the one named custom_probes. Using this option, you can test the validity of a set of functions before integrating it into the custom_probes file.

To Validate the custom_probes File

  1. Make sure the check script is located in the JumpStart directory.


    Note -

    The check script is in the Solaris_8/Misc/jumpstart_sample directory on the Solaris 8 Software 1 of 2 SPARC Platform Edition and Solaris 8 Software 1 of 2 Intel Platform Edition CD.


  2. Change to the JumpStart directory.

  3. Run the check script to validate the rules and custom_probes files.


    $ ./check [[-p path -r file_name]]

    As the check script runs, it reports the validity of the rules and custom_probes files and each profile. If no errors are encountered, it reports: "The custom JumpStart configuration is ok" and creates the rules.ok and custom_probes.ok files in the JumpStart directory.

  4. Is the custom_probes.ok file executable?

    • If yes, stop, you're done.

    • If no, type the command:

      chmod +x custom_probes