JP Vossen on 29 Mar 2009 14:12:23 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Determining Debian/Ubuntu distro and release?

Does anyone have a better method for determining the distro and release 
for Debian/Ubuntu?  /etc/issue isn't always consistent, 
/etc/debian-release doesn't help for Ubuntu, /etc/lsb-release isn't 
always there.

So far I have:

# Release code name (should be 5 lines)
codename=$(perl -ne 'print qq($1\n) if 
m!^deb.*?(?:debian|ubuntu)/\s+(\w+)\s+main!;' /etc/apt/sources.list)
[ -n "$codename" ] || {
     echo "Release codename not set, 'export codename=name' before 
     exit 2

# Debian or Ubuntu
     if   grep -q '' /etc/apt/sources.list; then
         # Do something
     elif grep -q '' /etc/apt/sources.list; then
         # Do something
         echo "/etc/apt/sources.list doesn't look like Debian or Ubuntu, 
         exit 3

JP Vossen, CISSP            |:::======|
My Account, My Opinions     |=========|
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --