brent timothy saner on 29 Mar 2009 14:18:44 -0700 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 JP Vossen wrote: > 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 You've touched on the major ones. I deal with a mix of Debian/Ubuntu/CentOS boxen at $work, and usually a combination of: cat /etc/issue cat /etc/issue.net lsb_release -a #usually not installed cat /etc/*-release uname -a yum;apt-get #whichever one doesn't exist is usually a pretty big tipoff between RPM vs DEB does the trick. never even thought to grep /etc/apt/sources.list, but i may just start doing so. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknP5ZIACgkQ8u2Zh4MtlQqtcQCcDptyJ7V+nZ8kf2E/0Isxm9qN NJ8AoMNqL+RHnjvnngja+xIAYT0TIIhw =VkeS -----END PGP SIGNATURE----- ___________________________________________________________________________ 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
|
|