Skip to contentSkip to conversation

Question about exception

DISCUSSION MARG 3 participants 3 messages Dec 11, 2005 – Dec 12, 2005

lore
Share & tools
lore

MARG

author
#0 lore raw

Hi,

I'm making this BASH script to install a ful web system in Linux:

-----------------------------------------------------------
#!/bin/bash

#
# Uncompress and pre-configure Apache
#
file="apache_1.3.34.tar.gz"

if [ ! -f "$file" ] ;
then
echo "file '$file' not found" >&2
exit 1
fi

tar -zxpvf $file
base_apache="${file%.tar.gz}"
cd $base_apache
./configure --prefix=/usr/local/httpd
cd ..

#
# Install MySQL
#
file="mysql-5.0.15.tar.gz"

if [ ! -f "$file" ] ;
then
echo "file '$file' not found" >&2
exit 1
fi

tar -zxpvf $file
base_mysql="${file%.tar.gz}"
cd $base_mysql
./configure --prefix=/usr/local/mysql || make || make install cd ..

#
# Install PostgreSQL
#
file="postgresql-8.1.0.bz2"

if [ ! -f "$file" ] ;
then
echo "file '$file' not found" >&2
exit 1
fi

# and so forth...
-----------------------------------------------------------

I'd like to abort the whole script, if some package compile aborts with an error.
For example, if there is an error compiling MySQL, i don't want the script to follow to PostgreSQL.
I want it to abort with an error.

How can i do this ?

Any help would be apreciated.

Warm regards,
MARG

#1 lore raw
Quoted 9 lines · MARG

I'm making this BASH script to install a ful web system in Linux:

I'd like to abort the whole script, if some package compile aborts with an error.
For example, if there is an error compiling MySQL, i don't want the script to follow to PostgreSQL.
I want it to abort with an error.

How can i do this ?

( ./configure ... && make && make install ) || exit 1

Signature · 1 line
Glynn Clements <[email protected]>