Managing HP Serviceguard for Linux, Tenth Edition, September 2012

Add service command(s)
Add a service restart parameter, if you so decide.
For more information about services, see the discussion of the service_ parameters
starting with service_name (page 215).
Adding Customer Defined Functions to the Package Control Script
You can add additional shell commands to the package control script to be executed
whenever the package starts or stops. Enter these commands in the CUSTOMER DEFINED
FUNCTIONS area of the script.
If your package needs to run short-lived processes, such as commands to initialize or
halt a packaged application, you can also run these from the CUSTOMER DEFINED
FUNCTIONS.
You can also use the CUSTOMER DEFINED FUNCTIONS to determine why a package
has shut down; see “Determining Why a Package Has Shut Down” (page 150).
An example of this portion of the script follows, showing the date and echo commands
logging starts and halts of the package to a file.
# START OF CUSTOMER DEFINED FUNCTIONS
# This function is a place holder for customer defined functions.
# You should define all actions you want to happen here, before the service is
# started. You can create as many functions as you need.
function customer_defined_run_cmds
{
# ADD customer defined run commands.
: # do nothing instruction, because a function must contain some command.
date >> /tmp/pkg1.datelog
echo 'Starting pkg1' >> /tmp/pkg1.datelog
test_return 51
}
# This function is a place holder for customer defined functions.
# You should define all actions you want to happen here, before the service is
# halted.
function customer_defined_halt_cmds
{
# ADD customer defined halt commands.
: # do nothing instruction, because a function must contain some command.
date >> /tmp/pkg1.datelog
echo 'Halting pkg1' >> /tmp/pkg1.datelog
test_return 52
}
# END OF CUSTOMER DEFINED FUNCTIONS
Adding Serviceguard Commands in Customer Defined Functions
You can add Serviceguard commands (such as cmmodpkg) in the Customer Defined
Functions section of a package control script. These commands must not interact with the
package itself.
276 Cluster and Package Maintenance