Viewing file: lsb_release (15.56 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/bin/sh
#
# lsb_release - collect LSB conformance status about a system
#
# Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc.
# Originally by Dominique MASSONIE
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# * Changes in 2.0
# - Support LSB 2.0 module layout (Mats Wichmann)
# The LSB_VERSION is now a colon-separated field of supported module versions
# An /etc/lsb-release.d is searched for modules beyond the core.
# Only the filenames in this directory is looked at, those names are added
# to LSB_VERSION. This allows module support to be handled easily by
# package install/removal without a need to edit lsb-release on the fly.
# - Correct license: FSG == Free Standards Group, Inc.
#
# * Changes in 1.4
# - "awk" not needed anymore (Loic Lefort)
# - fixed bug #121879 reported by Chris D. Faulhaber,
# some shells doesn't support local variables
# - fixed a bug when single parameter sets many args including -s
# - function DisplayProgramVersion (undocumented) now exits script like Usage
# - cosmetic changes in comments/outputs
#
# * Changes in 1.3
# - No changes in script, only in build infrastructure
#
# * Changes in 1.2
# - Fixed more bash'isms
# - LSB_VERSION is no longer required in /etc/lsb-release file
#
# * Changes in 1.1
# - removed some bash-ism and typos
# Notice: script remains broken with ash because of awk issues
# - changed licence to FSG - "Free Software Group, Inc"
# - fixed problem with --short single arg call
# - changed Debian specifics, codename anticipates release num
#
# Description:
# Collect information from sourceable /etc/lsb-release file (present on
# LSB-compliant systems) : LSB_VERSION, DISTRIB_ID, DISTRIB_RELEASE,
# DISTRIB_CODENAME, DISTRIB_DESCRIPTION (all optional)
# Then (if needed) find and add names from /etc/lsb-release.d
# Then (if needed) find and parse the /etc/[distro]-release file
###############################################################################
# DECLARATIONS
###############################################################################
# This script version
SCRIPTVERSION="2.0"
# Defines the data files
INFO_ROOT="/etc" # directory of config files
INFO_LSB_FILE="lsb-release" # where to get LSB version
INFO_LSB_DIR="lsb-release.d" # where to get LSB addon modules
INFO_DISTRIB_SUFFIX="release" # -
ALTERNATE_DISTRIB_FILE="/etc/debian_version" # for Debian [based distrib]
ALTERNATE_DISTRIB_NAME="Debian" # "
CHECKFIRST="/etc/redhat-release" # check it before file search
# Defines our exit codes
EXIT_STATUS="0" # default = Ok :)
ERROR_UNKNOWN="10" # unknown error
ERROR_USER="1" # program misuse
ERROR_PROGRAM="2" # internal error
ERROR_NOANSWER="3" # all required info not available
# typically non LSB compliant distro!
# Defines our messages
MSG_LSBVER="LSB Version:\t"
MSG_DISTID="Distributor ID:\t"
MSG_DISTDESC="Description:\t"
MSG_DISTREL="Release:\t"
MSG_DISTCODE="Codename:\t"
MSG_NA="n/a"
MSG_NONE="(none)"
MSG_RESULT="" # contains the result in case short output selected
# Description string delimiter
DESCSTR_DELI="release"
###############################################################################
# FUNCTIONS
###############################################################################
# Display Program Version for internal use (needed by help2man)
DisplayProgramVersion() {
echo "FSG `basename $0` v$SCRIPTVERSION"
echo
echo "Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc."
echo "This is free software; see the source for copying conditions. There\
is NO"
echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR\
PURPOSE."
echo
echo "Originally written by Dominique MASSONIE."
exit $EXIT_STATUS
}
# defines the Usage for lsb_release
Usage() {
echo "FSG `basename $0` v$SCRIPTVERSION prints certain LSB (Linux\
Standard Base) and"
echo "Distribution information."
echo
echo "Usage: `basename $0` [OPTION]..."
echo "With no OPTION specified defaults to -v."
echo
echo "Options:"
echo " -v, --version"
echo " Display the version of the LSB specification against which the distribution is compliant."
echo " -i, --id"
echo " Display the string id of the distributor."
echo " -d, --description"
echo " Display the single line text description of the distribution."
echo " -r, --release"
echo " Display the release number of the distribution."
echo " -c, --codename"
echo " Display the codename according to the distribution release."
echo " -a, --all"
echo " Display all of the above information."
echo " -s, --short"
echo " Use short output format for information requested by other options (or version if none)."
echo " -h, --help"
echo " Display this message."
exit $EXIT_STATUS
}
# Handles the enhanced args (i.e. --something)
EnhancedGetopt() {
getopt -T >/dev/null 2>&1 # is getopt the enhanced one ?
if [ $? = 4 ]
then # Yes, advanced args ALLOWED
OPT=$(getopt -o acdhirsvp \
--long all,codename,description,help,id,release,short,version,program_version \
-n 'lsb_release' \
-- "$@")
else # No, advanced args NOT allowed
# convert (if needed) the enhanced options into basic ones
MYARGS=$(echo "$@" bool(false)
|