#!/bin/sh set -e # read in dotfile pingmailrc=$HOME'/.pingmailrc' if [ ! -f $pingmailrc ]; then echo 'No .pingmailrc found at '$pingmailrc', aborting.' exit fi . $HOME'/.pingmailrc' mkdir -p $testdir # interpret arguments if [ "$1" = "check" ]; then continue elif [ "$1" = "touch" ]; then touch $ping_touch exit else echo 'usage: '$0' COMMAND\n(COMMAND one of "check", "touch")' exit fi # check test file for last modtime modtime_pingfile=0 if [ -f $ping_touch ]; then modtime_pingfile=`stat $ping_touch --format=%Y` fi # search mailbox or maildir for last life sign datetime modtime_mails=0 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 < wait time, send reminder to person to check with, start reminder # mail timer if not in existence, re-touch ping wait file if [ "$delta" -gt "$wait_time" ]; then echo $msg2checked | $mailclient_s "$subj2checked" $checked_address echo "Sending ping message." touch $ping_touch if [ ! -f "$reminder_touch" ]; then touch $reminder_touch echo "Creating reminder message wait time file." fi fi # if last life sign datetime / test file modtime > modtime of reminder touch # file, delete it; otherwise, if delta between those > wait time, send reminder # to person checking and then delete reminder touch file if [ -f "$reminder_touch" ]; then modtime_reminder=`stat $reminder_touch --format=%Y` if [ "$modtime" -gt "$modtime_reminder" ]; then rm $reminder_touch echo "Deleting reminder message wait time file." else delta=`expr $now - $modtime_reminder` if [ "$delta" -gt "$wait_time" ]; then echo $msg2checker | $mailclient_s "$subj2checker" $checker_address echo "Sending reminder message." rm $reminder_touch echo "Deleting reminder message wait time file." fi fi fi