|
|
This case study modifies a number of crontab files during package installation.
This case study shows examples of the following techniques:
You could use the build class and follow the approach shown for editing /etc/inittab in case study 5c except that you want to edit more than one file. If you used the build class approach, you would need to deliver one for each crontab file edited. Defining a cron class provides a more general approach. To edit a crontab file with this approach, you must:
Create an entry in the prototype(4) file for each crontab file which will be edited. Define their class as cron and their file type as e. Use the actual name of the file to be edited, as shown in the example.
These files contain the information you want added to the existing crontab files of the same name. See the sample root and sys files for two examples.
The i.cron script performs the following procedures:
This is done by setting the variable user to the base name of the cron class file being processed. That name equates to the user ID. For example, the basename of /var/spool/cron/crontabs/root is root (which is also the user ID).
Using the -l options tells crontab to send the standard output the contents of the crontab for the defined user.
The sample removal script is the same as the installation script except that there is no procedure to add information to the crontab file.
These procedures are performed for every file in the cron class.
PKG='case6' NAME='Case Study 6' CATEGORY='application' ARCH='3b2' VERSION='Version 1.0' CLASSES='cron'
i pkginfo i i.cron i r.cron e cron /var/spool/cron/crontabs/root ? ? ? e cron /var/spool/cron/crontabs/sys ? ? ?
# PKGINST parameter provided by installation servicewhile 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
# PKGINST parameter provided by installation servicewhile 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 0
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
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