Solved

Shell script to install rpms and verify

Posted on 2014-08-01
8
42 Views
Last Modified: 2016-07-17
Hi,

I am writing a shell script to install packages (rpms) that are required for oracle installation. I can install individually but want to write a script so that its easy.

First, I am creating a file called "pkgs" which contains the required packages (both 32 and 64 bit). BTW I am using Oracle Enterprise Linux 5.x 64 bit.

My script would call the packages from file "pkgs" and then removes a word called "(32 bit)" and send the out put to a different file. And then use yum install to install packages from a different file (using a for loop)

once completed then I want to verify if all the packages are installed correctly (both 32 vs 64) and this is where I ran to issues.  

Would someone please correct the script or suggest something?

Below is the script:

[root@localhost ~]# cat script1
#!/bin/bash

echo "Below are full pkg list"
echo
cat pkgs
echo
echo "We are now removing 32 bit tag from above pkgs"
echo
PKGNO32TAG=$(sed 's/(32 bit)/ /g' pkgs > pkgs.no32tag)
PKGONLY32=$(cat pkgs | grep -i "(32 bit)")
echo $PKGONLY32 > PKGONLY32LIST
PKGTRIM32TAG=$(sed -i 's/(32 bit)/ /g' PKGONLY32LIST  > pkg.trim32tag)
echo "removing 32 bit tag is complete and saved in pkg.trim32tag"

echo
echo "installing all pkgs using yum"
for a in `cat pkg.trim32tag`; do yum install -y $a; done
echo "done"

echo "checking if 32 bit pkgs are installed or not"
echo "list of total 32 bit pkgs"
echo
cat PKGONLY32LIST

echo "Now verifying"
for b in `cat PKGONLY32LIST`; do rpm -qa --qf "%{name}-%{version}-%{release}.%{arch}\n" $b; done

echo "done"


Below is the "pkgs" file contains the rpms:


[root@localhost ~]# cat pkgs
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3 (32 bit)
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-static-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-2.5-24 (32 bit)
glibc-common-2.5
glibc-devel-2.5
glibc-devel-2.5 (32 bit)
glibc-headers-2.5
ksh-20060214
libaio-0.3.106
libaio-0.3.106 (32 bit)
libaio-devel-0.3.106
libaio-devel-0.3.106 (32 bit)
libgcc-4.1.2
libgcc-4.1.2 (32 bit)
libstdc++-4.1.2
libstdc++-4.1.2 (32 bit)
libstdc++-devel 4.1.2
make-3.81
sysstat-7.0.2
unixODBC-2.2.11
unixODBC-2.2.11 (32 bit)
unixODBC-devel-2.2.11
unixODBC-devel-2.2.11 (32 bit)
openmotif


tanks
0
Comment
Question by:luser9999
  • 4
  • 2
8 Comments
 
LVL 61

Expert Comment

by:gheist
ID: 40233926
You can do same with YUM
Check this: http://yum.baseurl.org/wiki/YumGroups
0
 

Author Comment

by:luser9999
ID: 40234221
Yes, I do use YUM. I set up local YUM as well
0
 

Author Comment

by:luser9999
ID: 40234351
Any ideas or help regarding the script I wrote?

thansk
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 61

Accepted Solution

by:
gheist earned 500 total points
ID: 40234464
instead of (32bit) use .i?86
Then even on 32bit system it will go fine and accept default package

e.g
# yum install (-y) libstdc++-4.1.2 libstdc++-4.1.2.i?86
(i'd drop exact version to acomodate system patches e.g. libstdc++ libstdc++.i?86)

Yum exits cleanly (0) - it is installed fine, if other return code - something is missing.
0
 
LVL 61

Expert Comment

by:gheist
ID: 40234964
No need to reinvent the wheel

just
"yum install oracle-validated"
And you can run oracle installer right away.
0
 
LVL 61

Expert Comment

by:gheist
ID: 41713478
https:#a40234964
(works on Oracle Linux only)
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now