mars-mail/ohmessage

38 lines
1.3 KiB
Plaintext
Raw Normal View History

2011-11-13 00:46:51 +01:00
#!/bin/bash
2011-11-13 00:46:51 +01:00
#
# Ohmessage: called by ohmail and creates a database of new mail flags
# for users. Sends a message to mars or samba users informing them of
# new mail
# Please create a directory under /tmp called mail where the mail flags
# will be stored..
# log files will be stored in /var/log.
marsserver="yourmarsservername"
mailusr="genericmailuseronmars"
mailpwd="genericmailusrpasswd"
2011-11-13 00:46:51 +01:00
s1="`cat /var/spool/mail/$1 | grep Subject | wc -l`"
let s2=`cat /tmp/mail/$1`
if let "$s1 > $s2"
then
2011-11-13 00:46:51 +01:00
if cat /tmp/smbusers.list | grep " $1 " > /dev/null
2011-11-13 00:46:51 +01:00
then
2011-11-13 00:46:51 +01:00
for machine in `cat /tmp/smbusers.list | grep " $1 " | awk ' {print $5}' | sort | uniq`
2011-11-13 00:46:51 +01:00
do
echo "$1 has new mail `grep From: /var/spool/mail/$1 | tail --lines=1`" | smbclient -M $machine 2>&1 > /dev/null
echo $s1 > /tmp/mail/$1
echo "`date` -- Sent notification to SMB user $1 at $machine" >> /var/log/ohmessage.log
done
2011-11-13 00:46:51 +01:00
elif cat /tmp/nwusers.list | grep -i " $1 " > /dev/null
2011-11-13 00:46:51 +01:00
then
2011-11-13 00:46:51 +01:00
/usr/local/bin/nsend -S $marsserver -U $mailusr -P $mailpwd $1 "New mail `grep From: /var/spool/mail/$1 | tail --lines=1`"
2011-11-13 00:46:51 +01:00
echo $s1 > /tmp/mail/$1
echo "`date` -- Sent notification to NetWare user $1" >> /var/log/ohmessage.log
fi
else
echo $s1 > /tmp/mail/$1
fi
2011-11-13 00:46:51 +01:00
# ohmessage by gac@eng.rau.ac.za, eddie@eng.rau.ac.za