You can invoke a script as follows:
$ script-name command [args ...] |
A script performs the following basic steps:
Takes the RCM command from command-line arguments.
Executes the command.
Writes the results to stdout as name-value pairs.
Exits with the appropriate exit status.
The RCM daemon runs one instance of a script at a time. For example, if a script is running, the RCM daemon does not run the same script until the first script exits.
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
See the rcmscript(4) man page for a complete description of these RCM commands.
When you dynamically remove a device, the RCM daemon runs:
The script's register command to gather the list of resources (device names) that are identified in the script.
The script's queryremove/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.