0% found this document useful (0 votes)
93 views

Getinput KSH

The document contains Bash script code to automate the installation and configuration of Abinitio software. It removes existing files, copies configuration templates, creates configuration files, customizes environment variables, and installs RPM packages. Key steps include: 1. Removing existing files and templates 2. Creating configuration files like apphubrc from templates 3. Customizing environment variables in configuration files and templates based on inputs 4. Installing RPM packages and setting environment variables

Uploaded by

KUSHAL SARASWAT
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views

Getinput KSH

The document contains Bash script code to automate the installation and configuration of Abinitio software. It removes existing files, copies configuration templates, creates configuration files, customizes environment variables, and installs RPM packages. Key steps include: 1. Removing existing files and templates 2. Creating configuration files like apphubrc from templates 3. Customizing environment variables in configuration files and templates based on inputs 4. Installing RPM packages and setting environment variables

Uploaded by

KUSHAL SARASWAT
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

#!

/bin/bash
i=0
ch=0
x=0
ac=0
fg=0
rm file*
rm /home/kushal/tmp/envs/*.env
rm .sandbox.pset
cp .sandbox.pset_temp .sandbox.pset
rm /home/kushal/abinitio-AppHub-V3.2.6.15/config/apphubrc
rm /home/kushal/abinitio_config/*
rm /home/kushal/abinitio-V3.2.6.15/config/abinitiorc
##################################################

emchk=0
rcfile () {
rcpth=${pth}/config
echo "ORC path >> ${rcpth}"
echo "b>> ${b}"
if [[ ${b} = 'AppHub' ]];then
if [[ $(find "${rcpth}/apphubrc" | wc -l) = '0' ]] ;then
echo "Apphurc loop"
rcfnm=$(ls -tr ${rcpth}/apphubrc.example |rev|cut -d "/" -f1 |cut -d "." -f2|rev)
echo " Created ${rcfnm} in path ${rcpth}"
touch ${rcpth}/${rcfnm}
cat /home/kushal/tmp/apphubrc_temp >> ${rcpth}/${rcfnm} #change
sed -i "s|vr|${v}|g" ${rcpth}/${rcfnm}
aprcpth=$rcpth
else
echo "Apphubrc is present"
fi
else
#elif [[ $(ls -ltr ${rcpth} | grep -i ${a}rc | wc -l = '0') ]];then
if [[ $( find ${rcpth}/abinitiorc | wc -l) = '0' ]] 2>'/dev/null';then

echo "checking for shared.abinitio fine in /opt/abinitio_config"


#shpth="/opt/abinitio_config/"
shpth="/home/kushal/abinitio_config"
if [[ $(find "${shpth}/shared.abinitiorc" | wc -l) = '0' ]]
2>'/dev/null';then
echo "Shared.abinitio is not present"
shnt=1
if [[ $(find "/home/kushal/abinitio_config" | wc -l) = '0' ]] ;then
mkdir -p "/home/kushal/abinitio_config" #change
fi
touch "${shpth}/shared.abinitiorc"
echo "Creating Shared.abinitio"
cat "/home/kushal/tmp/shared.abinitio_temp" >> "${shpth}/shared.abinitiorc" #change
#echo "Creating Hostalias file enter the hostname as mentioned below"
#(cat abinitio/tmp/hostalias_temp) #change
#(cat /home/kushal/tmp/hostalias_temp)
h="${shpth}/hostalias"
touch ${h}
#echo "Enter the details make sure Syntax is correct"
z=0
for in in `cat file2 | sed -n '24,$p'`
do
#printf "Enter Alias and Hostname "
#echo " in testing >> $in"
htn=$( echo ${in} | grep -F host | cut -d "=" -f2)
#echo "Working host >> $htn"
echo ${htn}>>${h}
#read -r htn

#if [[ ${emchk} = '0' ]];then


#printf "Is this your EME Server too? Enter y >> (Yes) or n >> (No) "
#read emch
printf "\n"
#if [[ ${emch} = 'y' ]];then
#emtmp=$( echo ${htn} | cut -d " " -f1 )
#printf "Enter EME path also "
#read emtpth
sed -i "s|emhst|${emtmp}|g" "${shpth}/shared.abinitiorc"
sed -i "s|empth|${emtpth}|g" "${shpth}/shared.abinitiorc"
emchk=1
printf "\n"
#fi
#fi

printf "%s\t" ${htn} >> ${h}


printf "\n" >> ${h}
#echo " if you have Entered all the hostname Enter y >> (Yes) OR Else n >> (No)"
#read -r z
#if [[ ${z} = 'n' ]];then
#continue
#else
#break
#fi
done < file2
for item in $(cat ${h});do hst=$(cut -f1 | awk '{print}' ORS=' '); sed -i "s|alis|$
{hst}|" "${shpth}/shared.abinitiorc" ;done < ${h}
echo "Enter Control Center URL"
cc=$(cat file2 | grep -F ccurl | cut -d "=" -f2)
echo "Control Center $cc"
sed -i "s|ccurl|${cc}|g" "${shpth}/shared.abinitiorc"
sed -i "s|vr|${v}|g" "${shpth}/shared.abinitiorc"
echo "creating abinitiorc 1"
rcfnm=$(ls -tr "${rcpth}/abinitiorc.example" |rev| cut -d "/" -f1|cut -d "." -
f2|rev)
echo "Created ${rcfnm} in path ${rcpth}"
touch "${rcpth}/${rcfnm}"
echo "# system-wide config var settings
@include /opt/abinitio_config/shared.abinitiorc" >> ${rcpth}/${rcfnm}
else
echo "creating abinitiorc 2"
echo "Shared.abinitio is present"
rcfnm=$(ls -tr "${rcpth}/abinitiorc.example" |rev| cut -d "/" -f1|cut -d "." -f2
|rev)
echo " Created ${rcfnm} in path ${rcpth}"
touch "${rcpth}/${rcfnm}"
echo "# system-wide config var settings
@include /opt/abinitio_config/shared.abinitiorc" >> ${rcpth}/${rcfnm}

fi
#clear
else
echo "creating abinitiorc 3"
echo "Shared.abinitio is present"
rcfnm=$(ls -tr "${rcpth}/abinitiorc.example" |rev|cut -d "/" -f1| cut -d "." -
f2|rev)
echo " Created ${rcfnm} in path ${rcpth}"
touch "${rcpth}/${rcfnm}"
echo "# system-wide config var settings
@include /opt/abinitio_config/shared.abinitiorc" >> ${rcpth}/${rcfnm}

fi
fi }

stenv () {
printf "################Enter the MFS partition value you need to create for this
Server >> "
mfs=$( cat file2 | grep -F MFS | cut -d "=" -f2 )
echo "checking for mfs >> $mfs"
sed -i "12 s|Line12|"$mfs"|" $(pwd)/.sandbox.pset
(find ${stpth}) 2>'/dev/null'
if [[ $? = '1' ]];then
printf "\n"
tmpstpth=$( echo ${stpth} | rev | cut -d "/" -f2- | rev )
echo " $tmpstpth is not present ,Creating it" #mkdir -p ${stpth}
printf "\n"
fi

printf "#################### Checked out stdenv in $stpth and .Sandbox.pset has


been Custumized Accordingly >> "
}

exprt() {
if [[ $(cat ${Epath}/${Fenv} | grep -w "Line1" | wc -l) = '1' ]] ; then
sed -i "s|\<Line1\>|$pth|" ${Epath}/${Fenv}
sed -i "s/\<Line2\>/Line1/" ${Epath}/${Fenv}
sed -i "s|\<Line1\>|$pth|" $(pwd)/.sandbox.pset
sed -i "s|\<Line2\>|Line1|" $(pwd)/.sandbox.pset

else
#echo "########################Follwing Env Variable(s) of ${a} are needed for to
be customized ,Enter the LINE NUMBER and VARIABLE Value when
Prompted############################# :"

while read -r lines


do
var=$(echo $lines | cut -d "=" -f2 | sed -e 's/[0-9]//g' | sed 's/^[ \t]*//;s/[ \
t]*$//')
if [[ $var = 'Line' ]];then
ln=$(echo $lines |cut -d "=" -f2 |cut -d "e" -f2 )

echo "Variable > $var,Line >> $ln"


envlue=$(echo $lines | cut -d "=" -f1)
vl=$( cat file2 | grep -w $envlue | cut -d "=" -f2 )
echo " value find >> $vl"
#sed -n "/Line/p" ${Epath}/${Fenv}
#printf "\n"
#printf "#######################Enter the line number which you want to change >>
"
#read ln 2>'/dev/null'
#printf "########################Enter the Env Variable Value for corresponding
Line >> "
#read -r vl 2>'/dev/null'
sed -i "$ln s|Line$ln|"$vl"|" ${Epath}/${Fenv}
if [[ ${ln} = '10' ]] && [[ ${a} = 'abinitioCoOp' ]];then
stpth=$vl
vl=$(echo "$vl" | rev | cut -d "/" -f 2- | rev)
echo "Line 10 check :$vlcheck:$stpth"
sed -i "s|Line$ln|"$vl"|" $(pwd)/.sandbox.pset

stenv

elif [[ ${ln} = '3' ]] && [[ ${a} = 'abinitioCoOp' ]];then


if [[ ${shnt} = '1' ]];then
sed -i "s|Line$ln|"$vl"|" $(pwd)/.sandbox.pset

echo ">>In shared.abinitio & apphubrc loop modifying line 3"

sed -i "s|apth|"$rcApth"|g" ${shpth}/shared.abinitiorc


sed -i "s|Line3|"$vl"|g" ${shpth}/shared.abinitiorc
sed -i "s|Line3|"$vl"|g" ${rcpth}/apphubrc
vL=$(echo ${vl} | rev | cut -d "/" -f1 | rev)
echo "vL for rc file $vL"
sed -i "s|envL3|${vL}|g" ${rcpth}/apphubrc
sed -i "s|apth|"$rcCpth"|g" ${rcpth}/apphubrc
sed -i "s|envL3|${vL}|g" ${shpth}/shared.abinitiorc
else
sed -i "s|Line$ln|"$vl"|" $(pwd)/.sandbox.pset

echo "In Apphubrc in exprt"


sed -i "s|Line3|"$vl"|g" ${rcpth}/apphubrc
vL=$(echo ${vl} | rev | cut -d "/" -f1 | rev)
echo "vL for rc file $vL"
sed -i "s|envL3|"$vL"|g" ${rcpth}/apphubrc
sed -i "s|apth|"$rcCpth"|g" ${rcpth}/apphubrc

fi

else
sed -i "s|Line$ln|"$vl"|" $(pwd)/.sandbox.pset
fi
fi
done <${Epath}/${Fenv}
echo " "
fi

env (){
echo "testing version for abinitio >>$tpth : $a : $b "
cline=$(cat -s $tpth | sed -n /Line/p | wc -l )
#echo "Count $cline"
if [[ ${a} = 'abinitioCoOp' ]];then
((ac++))
if [[ ${ac} = '2' ]];then
while [[ ${cline} -gt '0' ]];
do
exprt
((--cline))
done
fi
elif [[ ${a} = 'oraClient' ]];then
exprt
fi
}
create() {
echo "Epath >> $Epath"
touch ${Epath}/${Fenv}
chmod 777 ${Epath}/${Fenv}
(cat ${cpth}/${tmpf}) >> ${Epath}/${Fenv}
echo " ${Fenv} file is created in $Epath"

install () {
ex=$(echo ${item} | rev|cut -d "/" -f1 |rev)
expath=$(echo ${item} | rev|cut -d "/" -f2- |rev)
echo " Exceutable name ${ex}; Executable path ${expath}"
echo " Installing ${a} software in ${pth}"
if [[ ${a} = 'MSTGenericClient' ]] || [[ ${a} = 'RSCD89_CTO' ]] || [[ ${a} =
'abinitioBRDServices' ]] ;then
#continue
#echo $?
for f in 1;do
break
done
else
cpth=$(pwd)
cd ${cpth}
tmpf=$(ls -tr | grep -i ${a})
#echo ${tmpf}
file=$(echo ${tmpf} | rev | cut -d ":" -f1 | rev)
Fenv=$(echo ${file} | sed -e "s/temp/$v/g")
echo "Env file will be named as ${Fenv}"
echo "flg: ${fg},Version:${v},Abinitio version:${AbV}"
if [[ ${fg} = '1' ]] && [[ ${v} = ${AbV} ]];then
Epath="${Abpth}"
exprt

for f in 1
do
continue
done
else
echo "**************************************************************
checking for path
*******************************" #path needs to be changed
Epath=$(cat file2 | grep -F Epath | cut -d "=" -f2) 2>'/dev/null'
fi
if [[ ${Epath} = 'y' ]];then
Epath="/home/kushal/tmp/envs"
if [[ $(echo ${Fenv} | cut -d "-" -f1) = 'ste' ]] && [[ ${fg} = '0' ]];then
$((fg++))
AbV=${v}
Abpth="${Epath}"
stAb=${Fenv}
fi
if [[ $(find ${Epath}/${Fenv} | wc -l ) = '1' ]] 2>'/dev/null' ;then
for f in 1
do
continue
done
else
create
fi
else
if [[ $(find ${Epath}/${Fenv} | wc -l) = '1' ]] 2>'/dev/null';then
for f in 1
do
continue
done
else
create
fi
fi
exprt
fi
tpth=${Epath}/${Fenv}
env

###################################################

while read -r line <&3


do
if [[ ${line} = 'Start' ]];then
flg=$line
$((i++)) 2>'/dev/null'
for f in 1;do
continue
done
fi
if [[ ${line} = 'End' ]];then
flg=$line
for f in 1;do
continue
done
fi
if [[ $flg = 'Start' ]];then
echo $line >> file${i}
fi
done 3<inputscript
IFS=$'\n'

(sort -r -o file1 file1)

for item in $(cat -s file1);


do
check=$(echo ${item} | rev | cut -d "." -f1|rev)
if [[ ${check} = "rpm" ]] 2>'/dev/null';then
echo $item

a=$(echo $item |rev|cut -d "/" -f1 | rev | cut -d "-" -f1)


echo "${a}"
if [[ ${a} = 'abinitioCoOp' ]];then
b=$(echo ${item} |rev| cut -d "/" -f1 | rev | cut -d "-" -f2)
echo " testing for b >> $b"
if [[ ${b} = 'AppHub' ]];then
Apath=$(echo $item | rev |cut -d "/" -f1 | rev | cut -d "-" -f1,2,3 | cut -d "." -
f1-4 | cut --complement -c 9-12)
echo "Apphub path /optware/${Apath} is created"
#pth=/optware/${Apath}
pth=/home/kushal/${Apath}
v=$(echo ${Apath} | cut -d "-" -f3)
echo "Version for Appub >> $v"
rcApth=$pth
rcfile
else
Cpath=$(echo $item |rev|cut -d "/" -f1 |rev| cut -d "-" -f1,2 | cut -d "." -f1-4 |
cut --complement -c 9-12)
echo "CoOp path /optware/${Cpath} is created"
#pth="/optware/${Cpath}"
pth=/home/kushal/${Cpath}
v=$(echo ${Cpath} | cut -d "-" -f2)
rcCpth=$pth
rcfile
fi
elif [[ ${a} = 'MSTGenericClient' ]] || [[ ${a} = 'RSCD89_CTO' ]] || [[ ${a} =
'abinitioBRDServices' ]] ;then
pth="/opt"
else
if [[ ${a} = 'oraK1CL' ]];then
a=oraClient
#echo " Created directory ${a} in path /optware"
Dpath=$(echo $item |rev|cut -d "/" -f1 | cut -d "-" -f2 | rev | cut -d "_" -f1)
echo " Created directory in path /optware/${a}/${Dpath}"
pth=/optware/${a}/${Dpath}
v=${Dpath}
else
#echo " Created directory ${a} in path /optware"
Dpath=$(echo $item |rev|cut -d "/" -f1 | cut -d "-" -f2 | rev | cut -d "_" -f1)
echo " Created directory in path /optware/${a}/${Dpath}"
pth=/optware/${a}/${Dpath}
v=${Dpath}
fi
fi
install

echo "***************************************************"
sleep 3
fi
done < file1

You might also like