123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #!/bin/sh
- #
- # This is a simple alternative to /usr/bin/lsb_release which
- # doesn't require python.
- #
- # If /etc/lsb-release exists then we use that to output data
- # in a compatible format to the original lsb_release utility.
- #
- # I consider this script trivial enough to be in the public-domain,
- # but any patches or suggestsions will be welcome.
- #
- # Steve
- # --
- #
- show_help() {
- cat << EOF
- Usage: lsb_release [options]
- Options:
- -h, --help show this help message and exit
- -i, --id show distributor ID
- -d, --description show description of this distribution
- -r, --release show release number of this distribution
- -c, --codename show code name of this distribution
- -a, --all show all of the above information
- -s, --short show requested information in short format
- EOF
- exit 0
- }
- #
- # Potential command-line options.
- #
- all=0
- codename=0
- description=0
- id=0
- release=0
- short=0
- version=0
- #
- # Process each argument, and set the appropriate flag
- # if we recognize it.
- #
- while :; do
- case $1 in
- -a|--all)
- all=1
- ;;
- -c|--codename)
- codename=1
- ;;
- -d|--description)
- description=1
- ;;
- -h|--help)
- show_help
- break
- ;;
- -i|--id)
- id=1
- ;;
- -r|--release)
- release=1
- ;;
- -s|--short)
- short=1
- ;;
- -v|--version)
- version=1
- ;;
- *)
- break
- esac
- shift
- done
- #
- # Read our variables.
- #
- if [ -e /etc/lsb-release ]; then
- . /etc/lsb-release
- else
- echo "/etc/lsb-release is not present. Aborting" >&2
- exit 1
- fi
- #
- # Now output the data - The order of these was chosen to match
- # what the original lsb_release used, and while I suspect it doesn't
- # matter I kept it the same.
- #
- if [ "$all" = "1" ] || [ "$id" = "1" ]; then
- if [ "$short" = "0" ]; then
- printf "Distributor ID:\t"
- fi
- echo $DISTRIB_ID
- fi
- if [ "$all" = "1" ] || [ "$description" = "1" ]; then
- if [ "$short" = "0" ]; then
- printf "Description:\t"
- fi
- echo $DISTRIB_DESCRIPTION
- fi
- if [ "$all" = "1" ] || [ "$release" = "1" ]; then
- if [ "$short" = "0" ]; then
- printf "Release:\t"
- fi
- echo $DISTRIB_RELEASE
- fi
- if [ "$all" = "1" ] || [ "$codename" = "1" ]; then
- if [ "$short" = "0" ]; then
- printf "Codename:\t"
- fi
- #
- # Codename comes from: VERSION="7 (wheezy)"
- #
- ver=$(echo $VERSION | awk '{print $2}' | tr -d \(\))
- echo "$DISTRIB_CODENAME"
- fi
- exit 0
|