LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-08-2007, 05:48 AM   #1
sardaukar_siet
Member
 
Registered: Feb 2003
Location: Warsaw
Distribution: Fedora 8
Posts: 58

Rep: Reputation: 15
Question Automated build and email log in bash


Hello!

I have a specific need for a script :

1. extract latest CVS
2. build the extracted snapshot (configure + make)
3. if successful, stop service, copy generated binary to a directory, restart service
4. mail me all output + time taken in each step (cvs retrieval, configure and make) + is service running

So far, I have 1 and 2 running :

Code:
#!/bin/bash

# Automatic MLDonkey compilation from CVS
# Run as root in home directory

cvs -z9 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/mldonkey co -P mldonkey
cd mldonkey
./configure
make
echo "MLDonkey build complete."
What is the best way to implement the remaining steps? Also, if I run this as a cron job, will I get two mails (from successful cronjob + script's own mail) ?

Thanks for any help!
 
Old 03-08-2007, 11:59 AM   #2
sardaukar_siet
Member
 
Registered: Feb 2003
Location: Warsaw
Distribution: Fedora 8
Posts: 58

Original Poster
Rep: Reputation: 15
Got it!

Code:
#!/bin/bash

# Automated MLDonkey build script - sardaukar.siet@gmail.com

MESSAGE="step incomplete"

echo $MESSAGE > /tmp/cvs-update.log
echo $MESSAGE > /tmp/configure.log
echo $MESSAGE > /tmp/make.log

START='build started '`date +"%m-%d-%Y %T"`

if [ -e /root/mldonkey/mlnet ]; then
rm /root/mldonkey/mlnet
fi

cd /root
cvs -z9 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/mldonkey co -P mldonkey &> /tmp/cvs-update.log && cd mldonkey && ./configure &> /tmp/configure.log && make &> /tmp/make.log

END='build ended '`date +"%m-%d-%Y %T"`

EMAIL="your email here"

if [ -e /root/mldonkey/mlnet ]; then
{
        SUM=`md5sum /root/mldonkey/mlnet | cut -d " " -f1`;
        echo "$START

$END" | mutt -s "mldonkey build successful [$SUM]" $EMAIL -a /tmp/cvs-update.log -a /tmp/configure.log -a /tmp/make.log ;
}
else
        echo "$START

$END" | mutt -s "mldonkey build failed" $EMAIL -a /tmp/cvs-update.log -a /tmp/configure.log -a /tmp/make.log
fi

rm /tmp/cvs-update.log
rm /tmp/configure.log
rm /tmp/make.log
 
  


Reply

Tags
bash, cron, cvs, mldonkey, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Build email offline on qmail and fetchmail vinhhv Linux - Networking 1 10-30-2006 03:08 AM
NVIDIA Mandriva LE 2005 Build Errors +log Damatie Mandriva 1 06-08-2005 01:58 PM
automated email list forwarding linuxhippy Slackware 9 05-22-2005 06:53 PM
chapter 5 - bash won't build shaurz Linux From Scratch 3 02-05-2003 04:00 AM
Glibc 2.3.1 build causes segfaults with static bash mdh Linux From Scratch 2 11-12-2002 06:08 PM


All times are GMT -5. The time now is 02:07 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration