[ale] Universal way to determine distro?

Bruce Jones bruce.jones at mindspring.com
Fri Jul 21 18:03:48 EDT 2006


Wow, even I can make that work :-)

Bruce

-----Original Message-----
>From: Jeff Lightner <jlightner at water.com>
>Sent: Jul 21, 2006 9:15 AM
>To: Atlanta Linux Enthusiasts <ale at ale.org>
>Subject: Re: [ale] Universal way to determine distro?
>
>I agree it's fairly neat.  I hadn't heard of the lsb_release command
>before.
>
>The script worked on my old RH 7.3 system as well as my Fedora Core 4
>and Fedora Core 5.
>
>By the way - the reason it used the else on FC 5 is because FC 5 has
>/etc/lsb-release.d directory rather than just the /etc/lsb-release file.
>He referenced this directory later in what he wrote but didn't test for
>it at beginning. 
>
>The following takes the snippet of code he so excellently created and
>makes it into a stand alone script.  It also adds the test for the
>directory mentioned above so it doesn't fall to the else on FC 5:
>
>#!/bin/bash
>#
># Script to show what Linux Distro the current system is
>#
>if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then
>     DISTRO=`lsb_release -i | cut -d: -f2 | sed s/'^\t'//`
>     DISTRO_REVISION=`lsb_release -r | cut -d: -f2 | sed s/'^\t//'`
>else
>     DISTRO=`ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v
>"lsb-release.d" | \
>             xargs cat | grep -v "=" | head -n 1 | cut -d\( -f1 | \
>             sed s/"Base System version "// | sed s/" release"//`
>fi
>echo Linux Distro is $DISTRO $DISTRO_REVISION
>
>-----Original Message-----
>From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of
>Cliff Free
>Sent: Thursday, July 20, 2006 9:12 PM
>To: Atlanta Linux Enthusiasts
>Subject: Re: [ale] Universal way to determine distro?
>
>A most excellent bit of shell scripting... surprisingly, Fedora Core 5
>has to fall through to the nasty else for non-LSB compliant
>distros.... but it does still work ;-)
>
>On 7/20/06, lists at stromberg.org <lists at stromberg.org> wrote:
>> > Good morning,
>> >
>> >    I guess this shows my lack of knowledge but is there a
>> > universal way to determine what distro a particular machine
>> > is running? I'd like to do this from bash or python, but I
>> > can't think of nor google anything useful. Any ideas?
>>
>> Here is one place where the LSB really made a difference. Check out
>the
>> lsb_release utility. This is from my ~/.zprofile that displays the
>distro
>> I've logged into. The really nasty "else" case is for truly ancient
>Linux
>> versions that have no LSB compliance:
>>
>>
>> if [ -f /etc/lsb-release ]; then
>>     DISTRO=`lsb_release -i | cut -d: -f2 | sed s/'^\t'//`
>>     DISTRO_REVISION=`lsb_release -r | cut -d: -f2 | sed s/'^\t//'`
>> else
>>     DISTRO=`ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v
>"lsb-release.d" | \
>>             xargs cat | grep -v "=" | head -n 1 | cut -d\( -f1 | \
>>             sed s/"Base System version "// | sed s/" release"//`
>> fi
>>
>>
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://www.ale.org/mailman/listinfo/ale
>>
>
>
>-- 
>"the best-laid schemes o' mice an' men gang aft agley" -- Robert Burns
>_______________________________________________
>Ale mailing list
>Ale at ale.org
>http://www.ale.org/mailman/listinfo/ale
>_______________________________________________
>Ale mailing list
>Ale at ale.org
>http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list