<chapter id="customprobes-1"><title>Creating Custom Rule and
Probe Keywords (Tasks)</title><highlights><para>This chapter provides information and procedures for creating your own
custom rule and probe keywords.</para><itemizedlist><listitem><para><olink targetptr="customprobes-2" remap="internal">Probe Keywords</olink></para>
</listitem><listitem><para><olink targetptr="customprobes-9" remap="internal">Creating a custom_probes
File</olink></para>
</listitem><listitem><para><olink targetptr="customprobes-13" remap="internal">Validating the custom_probes
File</olink></para>
</listitem>
</itemizedlist>
</highlights><sect1 id="customprobes-2"><title>Probe Keywords</title><para>To understand what a probe keyword is, you first need to recall what
a rule keyword is. A rule keyword is a predefined lexical unit or word that
describes a general system attribute, such as host name, <literal>hostname</literal>,
or memory size, <literal>memsize</literal>. Rule keywords and the values that
are associated with them enable you to match a system that has the same attribute
to a profile. This match of a system's attributes defines how the Solaris
software is to be installed on each system in the group. </para><para>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 <envar>SI_INSTALLED</envar> after
the <literal>installed</literal> rule keyword is used.</para><para>In some situations, you might need to extract the 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. Probe keywords extract
attribute information and remove the need for you to set up a matching condition
and run a profile.</para><para>For a list of probe keywords and values, see <olink targetptr="jumpstartreference-6" remap="internal">Probe Keywords and Values</olink>.</para>
</sect1><sect1 id="customprobes-9"><title>Creating a <filename>custom_probes</filename> File</title><para>The rule and probe keywords that are described in <olink targetptr="preparecustom-74" remap="internal">Rule Keywords and Values</olink> and <olink targetptr="jumpstartreference-6" remap="internal">Probe Keywords and Values</olink> might not
be precise enough for your needs. You can define your own custom rule or probe
keywords by creating a <filename>custom_probes</filename> file.</para><para>The <filename>custom_probes</filename> file is a Bourne shell script
that contains two types of functions. You must save the <filename>custom_probes</filename> file
in the same JumpStart directory where you saved the <filename>rules</filename> file.
The two types of functions that you can define in a <filename>custom_probes</filename> file
are as follows:</para><itemizedlist><listitem><para>Probe &ndash; Gathers the information you want or does the
actual work and sets a corresponding <envar>SI_</envar> environment variable
that you define. Probe functions become probe keywords.</para>
</listitem><listitem><para>Comparison &ndash; Calls a corresponding probe function, compares
the output of the probe function, and returns 0 if the keyword matches or
1 if the keyword does not match. Comparison functions become rule keywords.</para>
</listitem>
</itemizedlist><sect2 id="customprobes-3"><title>Syntax of the <filename>custom_probes</filename> File</title><para>The <filename>custom_probes</filename> file can contain any valid Bourne
shell command, variable, or algorithm.</para><note><para>You can define probe and comparison functions that require a single
argument in the <filename>custom_probes</filename> file. When you use the
corresponding custom probe keyword in the <filename>rules</filename> file,
the argument after the keyword is interpreted (as $1).</para><para>When you
use the corresponding custom rule keyword in the <filename>rules</filename> file,
the arguments are interpreted in sequence. The sequence starts after the keyword
and ends before the next <literal>&amp;&amp;</literal> or begin script, whichever
comes first.</para>
</note><para>The <filename>custom_probes</filename> file must meet the following requirements: </para><itemizedlist><listitem><para>Have
the name <filename>custom_probes</filename> </para>
</listitem><listitem><para>Have <literal>root</literal> as its owner</para>
</listitem><listitem><para>Be executable and have permissions set to 755</para>
</listitem><listitem><para>Contain at least one probe function and one corresponding
comparison function</para>
</listitem>
</itemizedlist><para>To improve clarity and organization, define all probe functions first,
at the top of the file, followed by all comparison functions.</para>
</sect2><sect2 id="customprobes-9a"><title>Syntax of Function Names in <filename>custom_probes</filename></title><para>The name of a probe function must begin with <literal>probe_</literal>.
The name of a comparison function must begin with <literal>cmp_</literal>.</para><para>Functions that begin with <literal>probe_</literal> define new probe
keywords. For example, the function <literal>probe_tcx</literal> defines the
new probe keyword <literal>tcx</literal>. Functions that begin with <literal>cmp_</literal> define new rule keywords. For example, <literal>cmp_tcx</literal> defines
the new rule keyword <literal>tcx</literal>.</para>
</sect2><task id="customprobes-12"><title>To Create a <filename>custom_probes</filename> File</title><procedure><step id="customprobes-step-70"><para>Use a text editor to create a Bourne
shell script text file.  Name the file <filename>custom_probes</filename>.</para>
</step><step id="customprobes-step-71"><para>In the <filename>custom_probes</filename> text
file, define your probe and comparison functions.</para><note><para>You can define probe and comparison functions that require arguments
in the <filename>custom_probes</filename> file. When you use the corresponding
custom probe keyword in the <filename>rules</filename> file, the arguments
after the keyword are interpreted in sequence (as $1, $2, and so on). </para><para>When you use the corresponding custom rule keyword in the <filename>rules</filename> file,
the arguments are interpreted in sequence. The sequence starts after the keyword
and ends before the next <literal>&amp;&amp;</literal> or begin script, whichever
comes first.</para>
</note>
</step><step id="customprobes-step-74a"><para>Save the <filename>custom_probes</filename> file
in the JumpStart directory next to the <filename>rules</filename> file.</para>
</step><step id="customprobes-step-4"><para>Ensure that <literal>root</literal> owns
the <filename>rules</filename> file and that the permissions are set to 644.</para>
</step>
</procedure>
</task><sect2 id="customprobes-10"><title>Examples of a <filename>custom_probes</filename> File
and Keyword</title><para>You can find additional examples of probe and comparison functions in
the following directories:</para><itemizedlist><listitem><para><filename>/usr/sbin/install.d/chkprobe</filename> on a system
that has the Solaris software installed</para>
</listitem><listitem><para><filename>/Solaris_11/Tools/Boot/usr/sbin/install.d/chkprobe</filename> on the Solaris Operating System DVD or on the Solaris Software - 1 CD</para>
</listitem>
</itemizedlist><para>The following <filename>custom_probes</filename> file contains a probe
and comparison function that tests for the presence of a TCX graphics card.</para><example id="customprobes-ex-6"><title><filename>custom_probes File</filename></title><programlisting role="complete">#!/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
  if
}</programlisting>
</example><para>The following example <filename>rules</filename> file shows the use
of the probe keyword that is defined in the preceding example, <literal>tcx</literal>.
If a TCX graphics card is installed and found in a system, <filename>profile_tcx</filename> is
run. Otherwise, <filename>profile</filename> is run.</para><note><para>Always place probe keywords at or near the beginning of the <filename>rules</filename> file. This placement ensures that the keywords are read and
run before other rule keywords that might rely on the probe keywords.</para>
</note><example id="customprobes-ex-7"><title>Custom Probe Keyword Used in a <filename>rules</filename> File</title><programlisting role="complete">probe tcx
tcx     tcx     -     profile_tcx     -
any     any     -     profile         -</programlisting>
</example>
</sect2>
</sect1><sect1 id="customprobes-13"><title>Validating the <filename>custom_probes</filename> File</title><para>Before you can use a profile, <filename>rules</filename>, and <filename>custom_probes</filename> file, you must run the <command>check</command> script
to validate that the files are set up correctly. If all profiles, rules, and
probe and comparison functions are correctly set up, the <filename>rules.ok</filename> and <filename>custom_probes.ok</filename> files are created. <olink targetptr="customprobes-tbl-2" remap="internal">Table 5&ndash;1</olink> describes what the <filename>check</filename> script does. </para><table frame="topbot" id="customprobes-tbl-2"><title>What Happens When You
Use the <command>check</command> Script</title><tgroup cols="2" colsep="0" rowsep="0"><colspec colname="column1" colwidth="44*"/><colspec colname="column2" colwidth="352*"/><thead><row rowsep="1"><entry><para>Stage</para>
</entry><entry><para>Description</para>
</entry>
</row>
</thead><tbody><row><entry><para>1</para>
</entry><entry><para><command>check</command> searches for a <filename>custom_probes</filename> file.</para>
</entry>
</row><row><entry><para>2</para>
</entry><entry><para>If the file exists, <command>check</command> creates
the <filename>custom_probes.ok</filename> file from the <filename>custom_probes</filename> file,
removes all comments and blank lines, and retains all Bourne shell commands,
variables, and algorithms. Then, <command>check</command> adds the following
comment line at the end:  </para><para><literal># version=2 checksum=num</literal></para>
</entry>
</row>
</tbody>
</tgroup>
</table><task id="customprobes-91711"><title>To Validate the <filename>custom_probes</filename> File</title><procedure><step id="customprobes-step-76"><para>Verify that the <command>check</command> script
is located in the JumpStart directory.</para><note><para>The <command>check</command> script is in the <filename>Solaris_11/Misc/jumpstart_sample</filename> directory on the Solaris Operating System DVD or on the Solaris Software - 1 CD.</para>
</note>
</step><step id="customprobes-step-77"><para>Change to the JumpStart directory. </para>
</step><step id="customprobes-step-78"><para>Run the <command>check</command> script
to validate the <filename>rules</filename> and <filename>custom_probes</filename> files. </para><screen>$ <userinput>./check</userinput> <userinput>-p</userinput> <replaceable>path</replaceable> <userinput>-r</userinput> <replaceable>file_name</replaceable></screen><variablelist><varlistentry><term><option>p</option> <replaceable>path</replaceable></term><listitem><para>Validates the <filename>custom_probes</filename> file by using
the <filename>check</filename> script from the Solaris software image for
your platform instead of the <filename>check</filename> script from the system
you are using. <replaceable>path</replaceable> is the image on a local disk
or a mounted Solaris Operating System DVD or Solaris Software - 1 CD.</para><para>Use this option to run the most recent
version of <command>check</command> if your system is running a previous version
of Solaris.</para>
</listitem>
</varlistentry><varlistentry><term><option>r</option> <replaceable>file_name</replaceable></term><listitem><para>Specifies a file name other than the one that is named <filename>custom_probes</filename>. By using the <option>r</option> option, you can
test the validity of a set of functions before integrating the functions into
the <filename>custom_probes</filename> file.</para>
</listitem>
</varlistentry>
</variablelist><para>As the <command>check</command> script
runs, the script reports the validity of the <filename>rules</filename> and <filename>custom_probes</filename> files and each profile. If no errors are encountered,
the script reports: &ldquo;The custom JumpStart configuration is ok&rdquo;
and creates the <filename>rules.ok</filename> and <filename>custom_probes.ok</filename> files
in the JumpStart directory.</para>
</step><step id="customprobes-step-20"><para>Determine if the <filename>custom_probes.ok</filename> file is executable.</para><itemizedlist><listitem><para>If yes, go to <olink targetptr="customprobes-step-5" remap="internal">Step&nbsp;5</olink>.</para>
</listitem><listitem><para>If no, type the following command.</para><screen># <userinput>chmod +x custom_probes</userinput></screen>
</listitem>
</itemizedlist>
</step><step id="customprobes-step-5"><para>Ensure that <literal>root</literal> owns
the <filename>custom_probes.ok</filename> file and that the permissions are
set to 755.</para>
</step>
</procedure>
</task>
</sect1>
</chapter>