Linux scripting help...

Scarpozzi

Lifer
Jun 13, 2000
26,389
1,778
126
I've never written a bash script before. I want to create a respository with some libraries I need often and script the download/install of them since they have to be done in a certain order. Is it as simple as putting them in a file and giving root execute rights? What syntax is required to script this. Should I put any delays in it? How would I do that?

I'm going to get a book next paycheck. I'm just trying to get started with a few basic scripts for now and will soon be automating anything I have to do more than twice. Thanks.

Here is what I've got t do:
#download
wget compat-gcc-7.3-2.96.128.i386.rpm
wget compat-gcc-c++-7.3-2.96.128.i386.rpm
wget compat-libstdc++-7.3-2.96.128.i386.rpm
wget compat-libstdc++-devel-7.3-2.96.128.i386.rpm
wget glibc-devel-2.3.4-2.43.i386.rpm
wget glibc-headers-2.3.4-2.43.i386.rpm
wget glibc-kernheaders-2.4-9.1.103.EL.i386.rpm
#install
rpm -iv --replacefiles compat-libstdc++-7.3-2.96.128.i386.rpm
rpm -ivh compat-libstdc++-devel-7.3-2.96.128.i386.rpm
rpm -ivh glibc-kernheaders-2.4-9.1.103.EL.i386.rpm
rpm -ivh glibc-headers-2.3.4-2.43.i386.rpm
rpm -ivh glibc-devel-2.3.4-2.43.i386.rpm
rpm -ivh compat-gcc-7.3-2.96.128.i386.rpm
rpm -ivh compat-gcc-c++7.3.2.96.128.i386.rpm

 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Well, the wgets won't work because they're not a full URLs. And I thought RPM was smart enough to reorder packages to satisfy dependencies so you should be able to do that all on one command.

But otherwise that should work because by default bash waits for each command to finish before moving on.
 

Scarpozzi

Lifer
Jun 13, 2000
26,389
1,778
126
I simplified the wgets...I'm going to be moving them to a local ftp.

I tried running rpm and it didn't handle the dependencies. That'd make this a lot easier if it could handle everything. I got too used to using software managers for installs that took care of dependencies for me...

I have everything in the right order, but if there's a specific command to get everything to install via RPM, I'd be happy to test it out. It'd simplify the script. I got it working and ran a test...I threw in a rpm -qa|grep compat command to list all the packages named compat for a crude comparison to make sure the packages needed are installed. I guess I could script that out further and check each file.

I can see that bash stuff is fun....what else should I do with it?

-Scar
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I tried running rpm and it didn't handle the dependencies. That'd make this a lot easier if it could handle everything. I got too used to using software managers for installs that took care of dependencies for me...

No, RPM doesn't automatically fix dependencies just like dpkg doesn't. But if 'rpm -ivh blah.rpm' works that means all of the dependencies are met so all of them should work if they work individually.

I can see that bash stuff is fun....what else should I do with it?

Depends on what you need, bash is virtually a full programming language. Although I tend to go to perl once things complicated to a point.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: Nothinman

t if 'rpm -ivh blah.rpm' works that means all of the dependencies are met so all of them should work if they work individually.

Not necessarily. That depends on whether the rpm was created properly.
 

M00T

Golden Member
Mar 12, 2000
1,214
1
0
I assume by the kernheaders version you want to install, this is either RHEL/CENTOS 2 or 3 ... ?

rpm -ivh glibc-kernheaders-2.4-9.1.103.EL.i386.rpm

In either of those releases, up2date can be configured to handle dependencies and install packages for you:

http://kbase.redhat.com/faq/docs/DOC-3631

I'd suggest copying over all the rpms from the install cds/dvd to /var/spool/RPMS/ and let up2date do your work for you. There's plenty of other fun things to learn bash scripting with.
 

Scarpozzi

Lifer
Jun 13, 2000
26,389
1,778
126
Originally posted by: M00T
I assume by the kernheaders version you want to install, this is either RHEL/CENTOS 2 or 3 ... ?

rpm -ivh glibc-kernheaders-2.4-9.1.103.EL.i386.rpm

In either of those releases, up2date can be configured to handle dependencies and install packages for you:

http://kbase.redhat.com/faq/docs/DOC-3631

I'd suggest copying over all the rpms from the install cds/dvd to /var/spool/RPMS/ and let up2date do your work for you. There's plenty of other fun things to learn bash scripting with.
I may end up doing that eventually. I've already got all the rpms downloading from my local repository and installing in the correct order. 4 or 5 of those have to be installed in a certain order to work and I've got it all documented and running smoothly. I'm actually scripting the rest of the prep for the installation of a larger product and have been testing it in VMware...it's nice because I'm able to do the install, then revert to a snapshot to make it work again. Fun stuff.

My next project is to get JVM6u14 and Tomcat6 installed and setup in the right directories for the app server install and I'll be set.
 

DaiShan

Diamond Member
Jul 5, 2001
9,617
1
0
You don't need to wget the files, you can rpm -ivh <web address of RPM> which will download and install the RPM. Also, to answer your original question, the simplest bash scripts are nothing more than a shabang (#!/bin/bash) and a list of commands that you wish to run. There are of course many more useful things that you can do in bash (loops, functions etc etc) but they aren't required to simply run a list of commands. There are also a lot of really great resources online for bash scripting, notably, http://tldp.org/LDP/abs/html/.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |