|
|
This study modifies a file which exists on the installation media during package installation. It uses one of three modification methods. The other two methods are shown in case study 5a and case study 5c. The file modified is /etc/inittab.
This case study shows examples of the following techniques:
To modify /etc/inittab during installation, you must:
Create a class called inittab. You must provide an installation and a removal class action script for this class. Define the inittab class in the CLASSES parameter in the sample pkginfo file.
This file contains the information for the entry that you will add to /etc/inittab. Notice in the sample prototype file that inittab is a member of the inittab class and has a file type of e for editable. The sample inittab file upon which this is based is also shown.
Because class action scripts must be multiply executable (you get the same results each time they are executed), you cannot just add our text to the end of the file. The sample class action script, performs the following procedures:
Note that init q can be performed by this installation script. A one-line postinstall script is not needed by this approach.
The sample removal script is very similar to the installation script. The information added by the installation script is removed and init q is executed.
This case study resolves the drawbacks to case study 5a. You can support multiple package instances because the comment at the end of the inittab entry is now based on package instance. Also, you no longer need a one-line postinstall script. However, this case has a drawback of its own. You must deliver two class action scripts and the inittab(4) file to add one line to a file. Case 5c shows a more streamlined approach to editing /etc/inittab during installation.
PKG='case5b' NAME='Case Study 5b' CATEGORY='applications' ARCH='3b2' VERSION='Version 1d05' CLASSES='inittab'
i pkginfo i i.inittab i r.inittab e inittab /etc/inittab ? ? ?
# PKGINST parameter provided by installation servicewhile read src dest do # remove all entries from the table that are # associated with this PKGINST sed -e "/^[^:]*:[^:]*:[^:]*:[^#]*#$PKGINST$/d" $dest > /tmp/$$itab || exit 2
sed -e "s/$/#$PKGINST" $src >> /tmp/$$itab || exit 2
mv /tmp/$$itab $dest || exit 2 done if [ "$1" = ENDOFCLASS ] then /sbin/init q || exit 2 fi exit 0
# PKGINST parameter provided by installation servicewhile read src dest do # remove all entries from the table that # are associated with this PKGINST sed -e "/^[^:]*:[^:]*:[^:]*:[^#]*#$PKGINST$/d" $dest > /tmp/$$itab || exit 2
mv /tmp/$$itab $dest || exit 2 done /sbin/init q || exit 2 exit 0
rb:023456:wait:/usr/robot/bin/setup