Managing Devices in Oracle® Solaris 11.2

Exit Print View

Updated: July 2014
 
 

About RCM Scripts

An RCM script can be any of the following:

  • An executable shell script (Perl, sh, csh, or ksh) or binary program that the RCM daemon runs. Perl is the recommended language.

  • A script that runs in its own address space by using the user ID of the script file owner.

  • A script that is run by the RCM daemon when you use the cfgadm command to dynamically reconfigure a system resource.

You can use an RCM script to release a device from an application when you dynamically remove a device. If the device is currently open, the RCM script also closes the device.

For example, an RCM script for a tape backup application can inform the tape backup application to close the tape drive or shut down the tape backup application.

Run an RCM script as follows:

$ script-name command [args ...]

An RCM script performs the following basic steps:

  1. Takes the RCM command from command-line arguments.

  2. Executes the command.

  3. Writes the results to stdout as name-value pairs.

  4. Exits with the appropriate exit status.

The RCM daemon runs one instance of a script at a time. Thus, if a script is running, the RCM daemon does not run the same script until the first script exits.

RCM Script Commands

    You must include the following RCM commands in an RCM script:

  • scriptinfo – gathers script information

  • register – registers interest in resources

  • resourceinfo – gathers resource information

    You might include some or all of the following RCM commands:

  • queryremove – queries whether the resource can be released

  • preremove – releases the resource

  • postremove – provides post-resource removal notification

  • undoremove – undoes the actions done in preremove

For a complete description of these RCM commands, see rcmscript(4) man page.

    When you dynamically remove a device, the RCM daemon runs the following:

  • The script's register command to gather the list of resources (device names) that are identified in the script.

  • The script's queryremove and preremove commands prior to removing the resource if the script's registered resources are affected by the dynamic remove operation.

  • The script's postremove command if the remove operation succeeds. However, if the remove operation fails, the RCM daemon runs the script's undoremove command.

RCM Script Directories

The following table shows the locations where you can store the RCM scripts.

Table 2-3  RCM Script Directories
Directory Location
Script Type
/etc/rcm/scripts
Scripts for specific systems
/usr/platform/`uname -i`/lib/rcm/scripts
Scripts for a specific hardware implementation
/usr/platform/`uname -m`/lib/rcm/scripts
Scripts for a specific hardware class
/usr/lib/rcm/scripts
Scripts for any hardware