Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Shell script to install rpms and verify

Posted on 2014-08-01
8
Medium Priority
?
82 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 62

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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 62

Accepted Solution

by:
gheist earned 2000 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 62

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 62

Expert Comment

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

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

722 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