Wednesday, 4 December 2013

Perl module installation script

#!/bin/bash

#####Checking shell########

if [ "$0" = "bash" ]
then
echo "Usage: bash scriptname  package.tar.gz"
exit
fi


###Checking error#########

error()
{
if [ $st -eq 0 ]
then
echo $succ
else
echo $fail
exit
fi
unset succ fail
}

###Untaring tar files#####

if [ ! $1 ]
then
echo "Please mention the tar filename"
stop
else
echo $1 | grep ".tar.gz"
st=$?
succ="File is in tar.gz format"
fail="File is not in tar.gz format"
error
gunzip -dc $1 | tar -xvf -
st=$?
succ="file untarer successfully"
fail="Unable to untar the file"
error
cd `basename $1 .tar.gz` && ls
fi


###Checking perl ##########

perl_e=`which perl | grep -i mpde`
if [ ! $PERL_ROOT ] && [ ! $perl_e ]
then
echo "You are using default perl version , do you want to continue ? y/n"
read per
if [ "$per" = "y" ] || [ "$per" = "Y" ]
then
echo "You are about to compile perl modules using default perl version"
else
break
fi
fi

#######Checking Oracle######

if [ ! $ORACLE_HOME ]
then
echo "Oracle is not set , Do you want to continue Y/N"
read ora
if [ $ora = "y" ] || [ $ora = "Y" ]
then
echo "You might not able to install compile some oracle based modules "
stop1
else
break
fi
fi

#####Perl compilation#########

perl Makefile.PL
st=$?
succ="Makefile created"
fail="Error in creating makefile"
gmake
st=$?
succ="Compiled successfully"
fail="Error during compilation"
error
gmake install
st=$?
succ="Perl modules compiled successfully"
fail="Error in compiling perl modules"
error

No comments:

Post a Comment