mailwatcher is this script:
#!/bin/bash
# set -x
# this was a test, was /bin/sh above, but /bin/sh is a softlink to /bin/dash
# REQUIRES your distros inotify-tools package, assume kde/kmail in use
# but might be adaptable to other agents too
# requires a ~/log directory, so mkdir it before running it
# you will also need to either do the housekeeping of this file, or
# figure out how to make logrotate do it for you.
WatchDir=/var/spool/mail/
# Setup temporary log
Log=mail.log
# put it in my home dir like fetchmail and procmail
Mlog=~/log
# in case it doesn't exist, make it
touch ${Mlog}/${Log}
# the command to send over dbus/dcop to make kmail pull the mailfile
#in /var/spool/mail
# First set method
Method=dcop
if [[ ${Method} = 'dbus' ]]
then
Cmd="/usr/bin/qdbus org.kde.kmail /KMail org.kde.kmail.kmail.checkMail"
fi
if [[ ${Method} = 'dcop' ]]
then
#or for dcop, use:
Cmd="/opt/trinity/bin/dcop kmail KMailIface checkMail"
fi
# Now, do forever
while :
do
sleep 1
if [ $(pidof -s kmail) ]
then
echo -n "Kmail is running " >>${Mlog}/${Log}
date -R >>${Mlog}/${Log}
sleep 1 # delay to give kmail a chance to settle in
# only start fetchmail once!
if [ $(pidof -s fetchmail) ]
then
sleep 1
echo -n "fetchmail already running "
>>${Mlog}/${Log}
date -R >>${Mlog}/${Log}
else
echo -n "starting fetchmail at " >>${Mlog}/${Log}
/usr/local/bin/fetchmail --fetchmailrc /home/gene/.fetchmailrc
>>${Mlog}/${Log} &
date -R >>${Mlog}/${Log}
fi
sleep 1 # delay to give kmail a chance to get its dcop/dbus sockets
setup?
$cmd
while [ $(pidof -s kmail) ]
do
# I've found that stderr needs dumped to /dev/null, so
InMail=`/usr/bin/inotifywait -q -e close_write --format %f
${WatchDir}` # 2>&1 >/dev/null
# and here it sits until inotifywait exits because of an incoming
mail
# and time later it will exit, setting $InMail to something, so
# recheck to make sure kmail is still about before sending the
signal
# as dbus/dcop seems to get a tummy ache if there is no receiver
if test "${InMail}" = "gene"
then
$Cmd
# sleep 1
# log it
echo -n ${InMail} >>${Mlog}/${Log}
echo -n " @ " >>${Mlog}/${Log}
date -R >>${Mlog}/${Log}
elif test "${InMail}" = "gene-from_linda"
then
$Cmd
# sleep 1
# log it
echo -n ${InMail} >>${Mlog}/${Log}
echo -n " @ " >>${Mlog}/${Log}
date -R >>${Mlog}/${Log}
elif test "${InMail}" = "amanda"
then
$Cmd
# sleep 1
# log it
echo -n ${InMail} >>${Mlog}/${Log}
echo -n " @ " >>${Mlog}/${Log}
date -R >>${Mlog}/${Log}
fi
done
# we don't have a pidof kmail, log that its gone
echo -n "Kmails pid is missing - it has stopped
">>${Mlog}/${Log}
date -R >>${Mlog}/${Log}
# Now, kill fetchmail too, and this is ok to do
killall fetchmail
# get rid of a waiting inotifywait, but this is not inotifywait instance
# sensitive and may kill the one for cocoprint.
killall inotifywait
fi
# and should be back in the outer loop, waiting for a kmail PID
done
but... its Apparentely not getting the dbus msg to kmail. and to me its magic so what do I
check next?
dbus is running:
root@coyote:/home/gene# ps -ea|grep dbus
696 ? 00:01:11 dbus-daemon
1768 ? 00:00:02 dbus-daemon
1975 ? 00:00:01 dbus-daemon
2955 pts/0 00:00:00 dbus-launch
2956 ? 00:00:00 dbus-daemon
13857 ? 00:00:00 dbus
13868 ? 00:00:00 dbus
thank you Steven, gene
Show replies by date
On Tue November 30 2021 16:39:01 Gene Heskett wrote:
mailwatcher is this script:
<snip>
What does this do that you can't do directly from KMail?
KMail
Settings
Configure Kmail
Accounts
Modify
Check Interval
--Mike