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 
running..."
     exit 2
}

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


Thanks,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP            |:::======|      http://bashcookbook.com/
My Account, My Opinions     |=========|      http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
"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         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug