On Fri, Apr 11, 2008 at 2:04 PM, Ray Van Dolson <rvandolson at esri.com> wrote:
> Any best practices for automating an addition to a user's crontab when
> installing and removing a package (for a package I'm creating)?
>
> In the RHEL world I can make use of /etc/cron.d/, should I set EDITOR
> to 'cat' and run crontab -e with a heredoc to add my line? :) Hmm,
> that probably wouldn't work...
I've done similar things, but when you are doing packaging it should
be able to install to and uninstall from alternate roots as well.
This is important for it to work with jumpstart, live upgrade, etc.
You could also do something like:
#! /bin/sh
echo "$crontabline" >> $PKG_INSTALL_ROOT/var/spool/cron/crontabs/$user
# Signal cron to re-read the crontab only if installing to a live system
if [ "$PKG_INSTALL_ROOT" -ef / ] ; then
EDITOR=touch crontab -e user
fi
You would also need a counterpart to run as the package is removed.
If you follow the discussions in this mailing list or pkg-discuss you
will already be aware that support for running such scripts is likely
to disappear in the next release of Solaris. So far I haven't seen a
pkg(1) action for cron jobs, but that is likely to be one of the
things that needs to be added. I'm not sure what the transition will
look like.
--
Mike Gerdts
http://mgerdts.blogspot.com/