X-Git-Url: https://plomlompom.com/repos/?p=pingmail.git;a=blobdiff_plain;f=pingmail;fp=pingmail;h=4724412b90d7c8bb2dcc3c89b1819c625a13e633;hp=0000000000000000000000000000000000000000;hb=1b3fa2e791597ba751b18fb321b4fe918aa98cbb;hpb=e92caefaebe7784d56827f8c6ff367b50ffe564a diff --git a/pingmail b/pingmail new file mode 100755 index 0000000..4724412 --- /dev/null +++ b/pingmail @@ -0,0 +1,87 @@ +#!/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 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 < 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 | mutt -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 | mutt -s "$subj2checker" $checker_address + echo "Sending reminder message." + rm $reminder_touch + echo "Deleting reminder message wait time file." + fi + fi +fi