treating cron file as a config file

Matthew Seaman m.seaman at infracaninophile.co.uk
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/crontab.in"
  else
      echo "---> Creating crontab(5) file for user \"%%USER%%\""
      /usr/bin/crontab -u "%%USER%%" "%%MAILMANDIR%%/cron/crontab.in" || exit 1
  fi

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/crontab.in >/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"
  else
      echo "---> Removing crontab for \"%%USER%%\""
      /usr/sbin/crontab -u "%%USER%%" -r
  fi

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         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 : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20040712/dcd79239/attachment.bin


More information about the freebsd-ports mailing list