#! /bin/sh # Copyright (c) 2002,3 Martin Schulze # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 dated June, 1991. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. revision='$Revision: 1.8 $' dir=$HOME/etc/atfile today=`date +%Y-%m-%d` today_=`date +%Y%m%d` sendmail=/usr/sbin/sendmail if [ -d /var/joey/fortunes ]; then fortunes=/var/joey/fortunes elif [ -d /org/infodrom.org/fortunes ]; then fortunes=/org/infodrom.org/fortunes fi cd $dir # Globbing, find all relevant files # files=`echo ${today}* ${today_}*` # Process all files, but test if they exist # for f in $files do case $f in *~) rm -f "$f" break;; esac if [ -f $f ] then subject=; from=; to= test "$TERM" == "dumb" || echo Processing $f if ! sed '/^$/,$d' $f | grep -q "^Subject: "; then subject="Subject: Reminder for $today"; fi if ! sed '/^$/,$d' $f | grep -q "^From: "; then from="From: $LOGNAME (Infodrom Reminder)"; fi if ! sed '/^$/,$d' $f | grep -q "^To: "; then to="To: $LOGNAME"; fi ( test -z "$to" || echo $to test -z "$from" || echo $from test -z "$subject" || echo $subject echo "Content-Type: text/plain; charset=iso-8859-1" echo "X-atfile: $f $revision" # Check if there needs to be an empty line test -z "$to" -o -z "$from" -o -z "$subject" || echo cat $f echo; echo "-- " /usr/games/fortune -s $fortunes ) | $sendmail -t rm -f $f fi done