This approach to modifying /etc/inittab uses the build class. A build class script is executed as a shell script and its output becomes the new version of the file being executed. In other words, the data file /etc/inittab that is delivered with this package will be executed and the output of that execution will become /etc/inittab.
The build class script is executed during package installation and package removal. The argument install is passed to the file if it is being executed at installation time. Notice in the sample build class script that installation actions are defined by testing for this argument.
To edit /etc/inittab using the build class, you must complete the following tasks:
Define the build file in the prototype file.
The entry for the build file in the prototype file
should place it in the build class and define its file
type as e. Be certain that the
CLASSES parameter in the pkginfo file is
defined as build.
Create the build class script.
The sample build class script performs the following procedures:
Edits the /etc/inittab file to remove any existing changes for this package. Notice that the file name /etc/inittab is hardcoded into the sed command.
If the package is being installed, adds the new line to the end of /etc/inittab. A comment tag is included in this new entry to describe where that entry came from.
Executes the init q command.
This solution addresses the drawbacks described in the case studies
in Modifying a File Using Standard Classes and Class Action Scripts and Modifying a File Using the sed Class and a postinstall Script.
Only one short file is needed (beyond the pkginfo and prototype files). The file works with multiple instances of a package
PKGINST parameter is
used, and no postinstall script is required since the init q command can be executed from the build