|
|||
3. Enhancing the Functionality of a Package (Tasks) 4. Verifying and Transferring a Package 5. Case Studies of Package Creation Soliciting Input From the Administrator Creating a File at Installation and Saving It During Removal Defining Package Compatibilities and Dependencies Modifying a File by Using Standard Classes and Class Action Scripts Modifying a File by Using the sed Class and a postinstall Script Modifying a File by Using The build Class Installing and Removing a Driver With Procedure Scripts Installing a Driver by Using the sed Class and Procedure Scripts |
Modifying crontab Files During InstallationThis case study modifies crontab files during package installation. TechniquesThis case study demonstrates the following techniques:
ApproachThe most efficient way to edit more than one file during installation is to define a class and provide a class action script. If you used the build class approach, you would need to deliver one build class script for each crontab file edited. Defining a cron class provides a more general approach. To edit crontab files with this approach, you must:
Case Study FilesThe i.cron and r.cron scripts described below are executed by superuser. Editing another user's crontab file as superuser may have unpredictable results. If necessary, change the following entry in each script: crontab $user < /tmp/$$crontab || to su $user -c "crontab /tmp/$$crontab" || The pkginfo CommandPKG=case7 NAME=Case Study #7 CATEGORY=application BASEDIR=/opt ARCH=SPARC VERSION=Version 1.0 CLASSES=cron The prototype Filei pkginfo i i.cron i r.cron e cron /var/spool/cron/crontabs/root ? ? ? e cron /var/spool/cron/crontabs/sys ? ? ? 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 #141,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 #20 * * * 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. |
||
|