Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Shell script to install rpms and verify

Posted on 2014-08-01
8
Medium Priority
?
91 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
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
Course of the Month10 days, 7 hours left to enroll

886 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