From owner-freebsd-ports@FreeBSD.ORG Wed Jun 18 06:26:08 2008 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C55901065686 for ; Wed, 18 Jun 2008 06:26:08 +0000 (UTC) (envelope-from walraven@terantula.com) Received: from mx.terantula.com (mx.terantula.com [212.61.39.65]) by mx1.freebsd.org (Postfix) with ESMTP id 7916F8FC1F for ; Wed, 18 Jun 2008 06:26:08 +0000 (UTC) (envelope-from walraven@terantula.com) Received: from localhost (localhost [127.0.0.1]) by mx.terantula.com (Postfix) with ESMTP id E5F7314A9A for ; Wed, 18 Jun 2008 08:26:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at terantula.com Received: from mx.terantula.com ([127.0.0.1]) by localhost (cotton.terantula.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gLGtWufN-5xf for ; Wed, 18 Jun 2008 08:26:04 +0200 (CEST) Received: by mx.terantula.com (Postfix, from userid 1002) id A72F514AA5; Wed, 18 Jun 2008 08:26:04 +0200 (CEST) Date: Wed, 18 Jun 2008 08:26:04 +0200 From: Marco Walraven To: freebsd-ports@freebsd.org Message-ID: <20080618062604.GI27681@cotton.terantula.com> References: <746214C8-3863-4B29-8B01-230579284C76@bitgravity.com> <112A6326AC722E927FB2A41E@Macintosh.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <112A6326AC722E927FB2A41E@Macintosh.local> User-Agent: Mutt/1.4.2.3i Organisation: Terantula Subject: Re: Question about ports adding cronjobs X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jun 2008 06:26:08 -0000 Hi David, On Tue, Jun 17, 2008 at 07:40:19PM -0500, Paul Schmehl wrote: > --On June 17, 2008 3:24:11 PM -0700 David Hawthorne > wrote: > > >I have a piece of software I've been working on that gaThers stats about > >the local host and shoves them into rrd files, with an accompanying web > >front-end page that generates pretty graphs from the RRDs on demand. I > >have a package done up for it, and I'd like to add it to the ports tree > >eventually, but I'm stuck on how to get it to automagically add the > >cronjob to have the stats gathering script run every five minutes, and I > >don't know of any ports that add cronjobs off the top of my head to go > >look at. > > > >Is there an approved standard for doing this? It doesn't have to be as > >root, either, it can run under a different user. Any advice on how to > >get the port to add the user (and remove it properly when the port is > >deinstalled) properly and securely would be appreciated as well. > > > > Look at mail/courier/files/crontab.in, > mail/exim/files/POST-INSTALL_NOTES.clamd and mail/mailman/pkg-install (and > those ports' associated files) for some examples of ways to deal with cron > jobs in a port. Just finished a project where we created a custom port section which has 20 ports currently. Some of them also automatically install a custom crontab. Actually ports should not be used to configure your system imho. However it can be easily done. What I did was adding a crontab snippet in a file under yourport/files, this is just one possibility. During installation of the port it gets added to a users crontab; it just uses 'cat' to do that. The snippet uses a tag # and ends with #!<-- end crontab for yourport --> which can be easily removed using 'sed' when you deinstall the port. By using these tags we now have multiple ports that can write a user's crontab without creating much clutter and scripting. You only need to restart cron if you install the port. Marco -- Terantula - Industrial Strength Open Source phone:+31 64 3232 400 / www: http://www.terantula.com / pgpkey: E7EE7A46 pgp fingerprint: F2EE 122D 964C DE68 7380 6F95 3710 7719 E7EE 7A46