tricks for fetchmail and signify
Here's a couple of tricks I worked up for using fetchmail and signify as
daemons. Put these in your .login or .profile .
First, I wanted to make sure fetchmail was running; answer, just run it
from the .login, right? But I didn't want to bitch about "waking up" to
grab mail that it was going to get in the next five minutes anyway. So we
use the handy, dandy pidof command:
/sbin/pidof /usr/bin/fetchmail >& /dev/null || fetchmail --daemon 300
Secondly, I like to have a rotating signature file. Signify is a pretty
good tool but it has two shortcomings that make the scenario a little more
complicated -- 1) it's a perl script, so pidof doesn't work (it matches
"perl", not "/usr/bin/signify" and 2) it doesn't nicely put itself in the
background like fetchmail does. The advantage is that it kindly sticks a
PID file in your home directory for you. So...
test -f $HOME/.signature.lock && ps `cat $HOME/.signature.lock` >& /dev/null \
|| (signify --fifo=$HOME/.signature &)
The fetchmail solution is a little weak, in that if more than one user is
fetching mail the pidof command will return pid's for all of them, so
fetchmail would fail to get started for you if anyone else was using. In
practice, only one user (me) fetches mail on my machine. If more are going
to do it, fetchmail should probably be run by root anyway.
I tried to implement these solutions using the start-stop-daemon, but I
encountered a number of difficulties with that approach, not the least of
which was that the "--help" option lied to me; if you give
start-stop-daemon an option it doesn't recognize, it dies instead of
passing on those options to the daemon you're calling (with --exec). Oh
Elegant improvements on these solutions would be most welcome, particularly the
fetchmail one (how do we determine if a particular user has a running
fetchmail process without doing an ugly grep/awk through the output of ps?).
Also, a design goal for me was to make sure these guys do their work dead
quiet. If the processes are dead, start them silently. If they're already
running, don't whine.
Somebody ought to put up a "Debian Tips and Tricks" webpage that features
stuff like the above (hopefully neater things, though).
G. Branden Robinson |
Purdue University | If encryption is outlawed, only outlaws
email@example.com | will @goH7OjBd7*dnfk=<q4fDj]Kz?.
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
Trouble? e-mail to firstname.lastname@example.org .