fetchmail-friends
[Top] [All Lists]

RE: [fetchmail]Patch request

2004-05-09 11:10:50
Thanks for help, I will try the named pipe solution.

On Sat, May 08, 2004 at 02:46:35PM +0200, cedric gross wrote:
I would like that daemonized fetchmail run a prog before
reading it's config
file (if it does so) and before it's fetching mails.

I don't know anything in C so I request from somebody a patch for doing
this. May be a new option like -r /bin/myprog .

I began to write a software (with perl) that generate the
config file from a
MySQL DB and I would like this tool run before fetchmail start fetching.

The simple and safe solution: write your daemon in perl. Make it do

   while (1) {
     generate_config();
     system("fetchmail");
     sleep(300);
   }

Or even simpler, just run from cron:

5 * * * *      generate_config && fetchmail

Otherwise, you can generate new configs whenever you feel like it, as long
as you move them into place in an atomic way (i.e. create foo.tmp, then
rename it to foo to replace the old foo in a single step). But you have to
accept that times when the config file is generated and the next fetchmail
iteration may not be in sync.

If you're being really clever, you could probably make
.fetchmailrc a named
pipe; your config generator would open it, send down a config (which
fetchmail would read when it was ready), and when it was closed,
go back to
the top. See "man mkfifo" for info on how to create named pipes.

All these solutions are "the Unix way" of doing things, and none requires
any change to fetchmail.

Regards,

Brian.




<Prev in Thread] Current Thread [Next in Thread>