Small shell script to regularly check a target person's responsiveness via mail.
+When run as "pingmail check", tries to derive the last time a person sent a
+mail to the local system by either a) searching a maildir for the most recent
+file matching a regex pattern (such as a "From: " field matching the target
+person), and looking at thta file's modification time, or b) checking the
+modification time of a defined mailbox file. If that point in time is too
+distant, sends an e-mail to the target person requesting some sign of life.
+After some more wait time without a sign of life, sends a warning message to
+another mail address that target person is unresponsive.
+
When run as "pingmail check", searches a maildir for the most recent file
matching a regex pattern (such as a "From: " field matching the target person),
and if the most recent file is too old, sends an e-mail to the target person
modtime_pingfile=`stat $ping_touch --format=%Y`
fi
-# search maildir for last life sign datetime
+# search mailbox or maildir for last life sign datetime
modtime_mails=0
-while read file; do
- if [ -z $file ]; then
- break
- fi
- modtime=`stat $file --format=%Y`
- if [ "$modtime" -gt "$modtime_mails" ]; then
- modtime_mails=$modtime
- fi
-done <<EOF
+if [ ! "$mbox" = "" ]; then
+ modtime_mails=`stat "$mbox" --format=%Y`
+else
+ while read file; do
+ if [ -z $file ]; then
+ break
+ fi
+ modtime=`stat $file --format=%Y`
+ if [ "$modtime" -gt "$modtime_mails" ]; then
+ modtime_mails=$modtime
+ fi
+ done <<EOF
$(grep -lER "$matchstring" $maildir)
EOF
+fi
# find delta of last life sign datetime / test file modtime and current datetime
now=`date +%s`
# modification time is when the count for sending checker a warning mail starts
reminder_touch=$testdir'/reminder_touch'
-# to recursively search for most recent matches to $matchstring as lifesigns
-maildir=$HOME'/mail'
-
# how long to wait for lifesigns before sending a ping; double is time to wait
# for a lifesign before sending a warning message to checker
wait_time=86400
# mail client command reading message body from stdin and subject from parameter
mailclient_s='mutt -s'
+# mailbox file to check for most recent life sign
+mbox=$HOME'/mail/foo'
+
+# to recursively search for most recent matches to $matchstring as lifesigns
+maildir=$HOME'/mail'
+
# pattern to search $maildir for recursively for lifesigns
checked_address_escaped=`echo $checked_address | sed 's/\./\\./g'`
matchstring='^From: .*('$checked_address_escaped'|alternate@example\.org)'