135 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			135 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/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
 |