DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Packaging your software applications

5b. Modify an existing file using a class action script

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.

Techniques

This case study shows examples of the following techniques:

Approach

To modify /etc/inittab during installation, you must:

  1. Create a class.

    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.

  2. Create an inittab(F) 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.

  3. Create an installation class action script.

    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.

  4. Create a removal class action script.

    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(F) file to add one line to a file. Case 5c shows a more streamlined approach to editing /etc/inittab during installation.

pkginfo file

   PKG='case5b'
   NAME='Case Study 5b'
   CATEGORY='applications'
   ARCH='3b2'
   VERSION='Version 1d05'
   CLASSES='inittab'

prototype file

   i pkginfo
   i i.inittab
   i r.inittab
   e inittab /etc/inittab ? ? ?

Installation class action script (i.inittab)

   # PKGINST parameter provided by installation service
   

while 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

Removal class action script (r.inittab)

   # PKGINST parameter provided by installation service
   

while 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

inittab file

   rb:023456:wait:/usr/robot/bin/setup

Next topic: 5c. Modify an existing file using the build class
Previous topic: postinstall script

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005