[ale] Universal way to determine distro?
Cliff Free
brd at alumni.clemson.edu
Thu Jul 20 21:12:25 EDT 2006
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
More information about the Ale
mailing list