Solved

Shell script to install rpms and verify

Posted on 2014-08-01
8
39 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
Comment Utility
You can do same with YUM
Check this: http://yum.baseurl.org/wiki/YumGroups
0
 

Author Comment

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

Author Comment

by:luser9999
Comment Utility
Any ideas or help regarding the script I wrote?

thansk
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 61

Accepted Solution

by:
gheist earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
https:#a40234964
(works on Oracle Linux only)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

772 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

11 Experts available now in Live!

Get 1:1 Help Now