Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
5.  Package Creation Case Studies Modifying crontab Files During Installation Case Study Files The prototype File  Previous   Contents   Next 
   
 

The i.cron Installation Class Action Script

# PKGINST parameter provided by installation service
while read src dest
do
user=`basename $dest` ||
exit 2
(crontab -l $user |
sed -e "/#$PKGINST$/d" > /tmp/$$crontab) ||
exit 2
sed -e "s/$/#$PKGINST/" $src >> /tmp/$$crontab ||
exit 2
crontab $user < /tmp/$$crontab ||
exit 2
rm -f /tmp/$$crontab
done
exit 0

The r.cron Removal Class Action Script

# PKGINST parameter provided by installation service
while read path
do
user=`basename $path` ||
exit 2
(crontab -l $user |
sed -e "/#$PKGINST$/d" > /tmp/$$crontab) ||
exit 2
crontab $user < /tmp/$$crontab ||
exit 2
rm -f /tmp/$$crontab
done
exit 

crontab File #1

41,1,21 * * * * /usr/lib/uucp/uudemon.hour > /dev/null
45 23 * * * ulimit 5000; /usr/bin/su uucp -c
"/usr/lib/uucp/uudemon.cleanup" >
/dev/null 2>&1
11,31,51 * * * * /usr/lib/uucp/uudemon.poll > /dev/null

crontab File #2

0 * * * 0-6 /usr/lib/sa/sa1
20,40 8-17 * * 1-5 /usr/lib/sa/sa1
5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A

Note - If editing of a group of files will increase total file size by more than 10K, supply a space file so the pkgadd command can allow for this increase. For more information on the space file, see "Reserving Additional Space on a Target System".


Installing and Removing a Driver With Procedure Scripts

This package installs a driver.

Techniques

This case study demonstrates the following techniques:

  • Installing and loading a driver with a postinstall script

  • Unloading a driver with a preremove script

For more information on these scripts, see "Writing Procedure Scripts".

Approach

  • Create a request script.

    The request script determines where the administrator wants the driver objects to be installed, by questioning the administrator and assigning the answer to the $KERNDIR parameter.

    The script ends with a routine to make the two parameters CLASSES and KERNDIR available to the installation environment and the postinstall script.

  • Create a postinstall script.

    The postinstall script actually performs the driver installation. It is executed after the two files buffer and buffer.conf have been installed. The postinstall file shown for this example performs the following actions:

    • Uses the add_drv command to load the driver into the system.

    • Creates a link for the device using the installf command.

    • Finalizes the installation using the installf -f command.

    • Creates a preremove script.

      The preremove script uses the rem_drv command to unload the driver from the system, and then removes the link /dev/buffer0.

Case Study Files

The pkginfo File

PKG=bufdev
NAME=Buffer Device
CATEGORY=system
BASEDIR=/
ARCH=INTEL
VERSION=Software Issue #19
CLASSES=none

The prototype File

To install a driver at the time of installation, you must include the object and configuration files for the driver in the prototype file.

In this example, the executable module for the driver is named buffer; the add_drv command operates on this file. The kernel uses the configuration file, buffer.conf, to help configure the driver.

i pkginfo
i request
i postinstall
i preremove
f none $KERNDIR/buffer 444 root root
f none $KERNDIR/buffer.conf 444 root root

Looking at the prototype file for this example, notice the following:

  • Since no special treatment is required for the package objects, you can put them into the standard none class. The CLASSES parameter is set to none in the pkginfo file.

  • The path names for buffer and buffer.conf begin with the variable $KERNDIR. This variable is set in the request script and allows the administrator to decide where the driver files should be installed. The default directory is /kernel/drv.

  • There is an entry for the postinstall script (the script that will perform the driver installation).

 
 
 
  Previous   Contents   Next