------------------------------------------------------------------------------ API for Hibernate Scriptlets ------------------------------------------------------------------------------ A scriptlet is written in shell code, and is simply sourced into the main script. This means it can potentially change a lot about the way suspending works. For sanity's sake though, their actions should be restricted to work through a small set of functions provided by the main hibernate script. These are documented below. A scriptlet can request both extra command-line arguments, or extra configuration file options. It can execute arbitrary commands during the suspend and resume process. NAMING ------ A scriptlet's name (filename) is restricted to alphanumerics and the underscore (_) character. Otherwise, things will break! It must not conflict with an existing script (the hibernate script will warn if it does). Function and variable names within the scriptlet should be sufficiently unique (eg, prefixed with the name of the scriptlet). STDOUT/STDERR ------------- A scriptlet should use vecho rather than echo, and choose a verbosity level appropriately (see vecho, below). All scriptlet output is automatically sent to $LOGPIPE FUNCTIONS --------- AddSuspendHook NN function_name This will add the given function to the chain of functions called at suspend. NN must be a number between 00 and 99, inclusive (see ORDERING section below). A scriptlet should only add a function to the suspend chain until it knows that it is going to do work (eg, it parses a config option to do something). eg: AddSuspendHook 55 SuspendHair AddResumeHook NN function_name Similar to above. See ORDERING section below. eg: AddSuspendHook 55 ResumeHair AddConfigHandler function_name The given function_name will be called when a configuration file line is read and hasn't been handled already. The entire line is passed as parameters to the function. The function must return 0 if it handled the function, and 1 otherwise. eg: AddConfigHandler HairParseConfig AddConfigHelp Similar to above, but for configuration file options. eg: AddConfigHelp "HairTime " "Allows some extra time to wash your hair while suspending." AddOptionHandler function_name The given function_name will be called when a command line option is received that hasn't been handled already. If the option has no parameter, then the function is called with a single paramter, which is the option itself in single quotes (eg, '-t' or '--time'). If the option has a parameter linked with it, the function is called with two parameters - the first is the option, as before and the second is the parameter. The function must return 0 if it handled the function, and 1 otherwise. eg: AddOptionHandler HairParseOptions AddShortOption