Date: Wed, 18 Jun 2008 08:26:04 +0200 From: Marco Walraven <m.walraven@terantula.com> To: freebsd-ports@freebsd.org Subject: Re: Question about ports adding cronjobs Message-ID: <20080618062604.GI27681@cotton.terantula.com> In-Reply-To: <112A6326AC722E927FB2A41E@Macintosh.local> References: <746214C8-3863-4B29-8B01-230579284C76@bitgravity.com> <112A6326AC722E927FB2A41E@Macintosh.local>
next in thread | previous in thread | raw e-mail | index | archive | help
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 > <dhawth@bitgravity.com> 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 #<!-- begin crontab for yourport --> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080618062604.GI27681>