Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

RPM Download Request

by carlriz (Beadle)
on Jul 07, 2014 at 14:58 UTC ( [id://1092594]=perlquestion: print w/replies, xml ) Need Help??

carlriz has asked for the wisdom of the Perl Monks concerning the following question:

I was not sure how to do this, so I came here. I am writing a script that checks to see if a rpm is installed on a linux system. If it is not, I want it to automatically download it from a website, install, and configure it. Anyone done this before or have an idea on how to do it?

Replies are listed 'Best First'.
Re: RPM Download Request
by wjw (Priest) on Jul 07, 2014 at 15:06 UTC

    A number of years ago, I used Kickstart for this. IIRC, I used Perl to control the process.

    Hope that is helpful....

    Update:

    ReiVo brings up a good point in Re^2: RPM Download Request. My experience with Kickstart was in a controlled environment where we had to maintain numerous identical workstations. The company I worked for had an agreement with RedHat(some version of enterprise support I seem to recall). Kickstart was our way of managing the identical state of machines. It was not unattended. I agree that un-attended updates are a bad idea. However, having a repeatable process across multiple machines does not imply un-attended. Just automated. Big difference. To minimize issues like internet connectivity during upgrades, we downloaded the ISO images and mounted them prior to selecting distribution to the LAN connected workstations. And prior to that, we updated the config for kickstart to ensure we got what we wanted. We deployed to a test workstation first, checked for functionality etc... , then if all was well (and it always was), we deployed during lunch breaks on off-shifts to minimize engineering downtime.

    The point is that there are tools to do the job, and appropriately applied, they work well. Kickstart is just one I happen to recall working well with RPM based installs and updates/upgrades. Thanks RieVo for bringing that up.

    ...the majority is always wrong, and always the last to know about it...

    Insanity: Doing the same thing over and over again and expecting different results...

    A solution is nothing more than a clearly stated problem...otherwise, the problem is not a problem, it is a facct

      Well, first of all, I would ask you: Is this really something you want to do ?
      Micro$oft installs automagically software packages when they get available and that is the reason why sometimes you have to wait until you can close your notbook and put it into its bag.
      You should understand what your SW should do, if somthings go wrong ( file system full, Internet connection breaks down, conflicting versions, ... ). In my years as sysadmin I was never happy with unattended package installations. Said that, in Unix you have a powerful shell, which can do a lot of things included running commands. I would use the tool expect, which is written exactly for your purpose. I.E. executing commands and react on the output.
      Anyway, have fun ....

        Attended package installations don't scale further than a handful of systems. Unattended package installations scale to millions of systems.

        I've installed packages on many thousands of HP-UX and Linux servers and cluster nodes as part of my day job for many years using homebrew scripts, HP's software distributor, cfengine, and more recently puppet. Normally I only get something like a 0.05% to 0.5% failure rate and that's normally due to either hardware failure or a network issue that's gone away next run. If you can't trust your systems to install a package cleanly your systems are too dirty. You should know what versions of things they are running and you should have the filesystems split so users can't fill system disks.

      Kickstart installs whole systems, it doesn't install individual packages on an already running system. I suspect you are thinking of RedHat Network, RedHat Satellite Server, or maybe puppet or cfengine.

Re: RPM Download Request
by 1s44c (Scribe) on Jul 07, 2014 at 20:03 UTC

    There are tools that do this, good tools. If you are managing many packages on many systems you should look into Puppet, or RedHat Satellite Server.

    To answer the question you asked for random package 'bc':

    #!/usr/bin/perl -w my $package='http://mirror.1000mbps.com/centos/6/os/i386/Packages/bc-1 +.06.95-1.el6.i686.rpm'; my $result=`rpm -q bc`; if ( $result =~ /not installed/ ) { system "rpm -i $package"; }

    RPM does all the heavy lifting here. It can download from a URL and install. Any production script should include error checking. Also RPM itself will fail if that package needs uninstalled dependencies, if you have a version of RHEL that isn't 6, or if you are not running i386 or x86_64.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1092594]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-19 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found