treating cron file as a config file

Matthew Seaman m.seaman at
Mon Jul 12 12:37:08 PDT 2004

On Mon, Jul 12, 2004 at 02:51:24PM -0400, Vivek Khera wrote:
> It has been pointed out to me that the Mailman port stomps over any 
> alterations to the cron file when it is upgraded.  I'd like to fix 
> this, but I'm unsure how to do it.
> Currently, upon install, the port installs the stock cron job file, and 
> upon de-install removes that file.
> Ideally, we should be able to treat the cron file as we do normal 
> config files, but it is not a standard file in the file system since it 
> needs to be installed/removed via the crontab utility.
> How might I fake this out? I'd appreciate any ideas. Thanks.

In your pkg-install script, try something like this, which installs
the crontab only if the %%USER%% doesn't already have one:

  if /usr/bin/crontab -u "%%USER%%" -l >/dev/null 2>&1 ; then
      echo "---> \"%%USER%%\" already has a crontab.  Not overwriting it"
      echo "---> Please merge any changes from the standard crontab file"
      echo "--->     %%MAILMANDIR%%/cron/"
      echo "---> Creating crontab(5) file for user \"%%USER%%\""
      /usr/bin/crontab -u "%%USER%%" "%%MAILMANDIR%%/cron/" || exit 1

In the pkg-deinstall script, you could de-install the crontab file
only if it's identical to the default:

  if /usr/bin/crontab -u "%%USER%%" -l | \
      /usr/bin/diff - %%MAILMANDIR%%/cron/ >/dev/null 2>&1 ; then
      echo "---> Crontab for \"%%USER%%\" not removed: please deinstall"
      echo "---> manually if you no-longer wish to use Mailman. eg:"
      echo "--->     /usr/sbin/crontab -u "%%USER%%" -r"
      echo "---> Removing crontab for \"%%USER%%\""
      /usr/sbin/crontab -u "%%USER%%" -r



Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP:         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-ports mailing list