I was trying to get templates to work on evolution and found that although templates are there in evolution mail client, its not that efficient to use. What I thus wanted was to have something that could allow me to send mails to (and cc and bcc) to specified people with predefined template, only some values changed, like changelog and so on. So I wrote a set of files and below files to achieve the same. Hope it helps you too 🙂
First we will have a file called \”fields\” containing all the variable that we intend to use:
Ok, so here we are defning the to field, cc field and the other fields along with the name of the file to attach. Next we need the template to use. Create a file called \”template.changelog\” as defined in the above file:
Please find the changelog for $tag for $product-$customer. Issue addressed : $issue .
Next we have a shell script called \”mail.sh\” to actually send the mail. Here is the script:
rm -rf .temp .temp1
sed \”s/\\$product/$product/g\” $template > .temp1
sed \”s/\\$customer/$customer/g\” .temp1 > .temp
sed \”s/\\$issue/$issue/g\” .temp1 > .temp1
sed \”s/\\$tag/$tag/g\” .temp1 > .temp
rm -f .temp1
sendEmail -xu user -xp pass -s server -f agarwal -t \”$to\” -cc \”$cc\” -u \”[$product-$customer]:$subject for $issue\” -o message-file=.temp -a $attachment
echo \”Mail sent with \\nSubject $subject \\nto $to \\nand copied to $cc and \\nattached $attachment\”
In the shell script I am using sendEmail, but you can use any MTA that you want. 🙂
Well, I think you get the idea, so you can modify the script to include the necessary checks and modify according to your needs.
On my personal desktop at home, I like to see the statistics at least once a day, for what was installed, what was run with sudo and other such details like kernel errors.
Running this monotonously every day is quite boring, so comes to rescue is logwatch. I have Fedora installation so I will talk about the location with respect to that so for your distribution it might be a little different.
First install logwatch using 🙂 yum install logwatch
and you are done.
If you need to do more configuration and want to see something different in the mail that is sent( BTW sendmail is assumed to be default mail client), the keep reading.
First open the file /etc/logwatch/conf/logwatch.conf
The contents for my distro is just one line 🙂
# Local configuration options go here (defaults are in /usr/share/logwatch/default.conf/logwatch.conf)
So, open the file /usr/share/logwatch/default.conf/logwatch.confbr
I will highlight the important lines in the file here:
LogDir = /var/log — This is the directory for all the log files
MailTo = root — Whom should the mail be sent to
Print = If this is set to true then there will be no mail sent and the output will be displayed on the stdout.
Detail = The level of details you want to see in the mail or the output on screen.
Thats pretty much it.. If you want to further modify the details in the mail you can configure the services. For more advanced usage you can even go to /usr/share/logwatch/scripts/services and configure the individual scripts.
If you have some affiliate links and are concerned about their presence then you can setup cron to check the links for you regularly. For this you need a very simple script (as below) and a cron entry (example further down).
# FILE: checklinks.sh
# USAGE: ./checklinks.sh
# DESCRIPTION: Check if the links exists on affiliate sites
# OPTIONS: —
# REQUIREMENTS: —
# BUGS: —
# NOTES: —
# AUTHOR: Amit Agarwal (AKA), firstname.lastname@example.org
# COMPANY: Individual
# VERSION: 1.0
# CREATED: 04/07/2010 08:19:29 AM IST
# REVISION: —
websites=\”space seperated website address like http://amit-agarwal.co.in http://blog.amit-agarwal.co.in\”
echo \”Checking the sites for Links\”
echo $websites|tr \’ \’ \’\\n\’
for i in $websites
curl -s $i |grep amit-agarwal.co.in > /dev/null
if [ $? != 0 ]
echo \”Link not found on $i\”
Then make a crontab entry like this:
40 08 * * * (echo \”Subject: Link verification on affiliate sites @ `date`\”;<fullpath>/checklinks.sh) |/usr/sbin/sendmail <email>