Open topic with navigation
LifeKeeper executes the remove script for a particular resource type whenever it needs to take a particular instance of that type out of service. This section discusses the remove script for file system type resources found on a LifeKeeper system in the following directory: /opt/LifeKeeper/subsys/gen/Resources/filesys/actions.
The LRACI program that runs the remove script places the resource instance into the OSU state if it completes successfully (exit code 0) and leaves the state unchanged if it fails.
The topic Sections Common to Remove and Restore Scripts highlights the first three sections of the script that are the same in both the remove and the restore scripts. You are encouraged to copy these sections as a starting point for your own script development. The topic Sample Remove Script, providing the functional processing section of a file system remove script, displays the rest of the remove script.
These are the five basic parts of the recovery script:
Initialization. All LifeKeeper scripts source /etc/default/LifeKeeper in order to set certain required environment variables, most especially PATH and LKROOT.
Calling parameter parsing. LifeKeeper calls every recovery script with at least two options:
The script may use either or both of these parameters to determine which specific instance to remove. In this example, the file system remove script uses only the instance_id (the file system mount point). If the instance is a resource type you created, then you would determine the format and meaning of the instance_id. Although the -R parameter is optional, you should always include lines 37-39 in recovery scripts because prfuncs uses the variable RCVARG.
Error logging. Line 56 reads into the script the contents of the prfuncs file. This file contains a number of error logging utilities needed throughout the script. The prfuncs manual page describes the functions log, pl and pt.
Termination processing. It is good shell-programming practice to include signal trapping so that the script can clean up after itself when it terminates, whether normally or otherwise. In the remove example, the trap function removes any temporary files and sends a completion message to the LifeKeeper log.
Note the use of the err variable in the script to ensure that the proper exit code is returned to LifeKeeper regardless of termination mode. If the remove script returns a failure exit code (anything other than 0), LifeKeeper stops switchover or failover for the hierarchy involved.
Functional processing. The part of the remove script shown in the topic Sample Remove Script actually removes the file system instance from service. The script specifies these actions:
Checks that the file system is mounted. The script first performs some checks to verify that the specified file system is mounted. If it is not mounted, the process does not need to unmount it but ends successfully because the intended result is achieved.
Kills processes using the file system. Before unmounting the file system, the script kills off any processes using the file system so that it can be unmounted.
Unmounts the file system. If the process cannot immediately unmount the file system, the script provides a wait time to be sure there has been enough time for user processes to die. The script sets err to 0 only after a successful unmount.
© 2012 SIOS Technology Corp., the industry's leading provider of business continuity solutions, data replication for continuous data protection.
Open topic with navigation