| 1 | #!/bin/bash |
| 2 | # |
| 3 | # lsb_release command for testing the ld module. |
| 4 | # Only the -a option is supported. |
| 5 | # |
| 6 | # This version of the lsb_release command reads an lsb-release file. |
| 7 | # |
| 8 | # The lsb-release file has the usual format, e.g.: |
| 9 | # DISTRIB_ID=Ubuntu |
| 10 | # DISTRIB_RELEASE=14.04 |
| 11 | # DISTRIB_CODENAME=trusty |
| 12 | # DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS" |
| 13 | # Where each line is optional. If a line is missing, the default value |
| 14 | # will be the empty string. |
| 15 | # |
| 16 | |
| 17 | if [[ "$@" != "-a" ]]; then |
| 18 | echo "Usage: lsb_release -a" |
| 19 | exit 2 |
| 20 | fi |
| 21 | |
| 22 | # Because the PATH is set to just this directory, we cannot use 'dirname' |
| 23 | # or other external programs, but need to use built-in abilities of bash. |
| 24 | LSB_FILE="${0%/*}/../etc/lsb-release" |
| 25 | |
| 26 | if [[ ! -f $LSB_FILE ]]; then |
| 27 | echo "Error: LSB release file does not exist: $LSB_FILE" |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | source $LSB_FILE |
| 32 | |
| 33 | echo "LSB Version: ${LSB_VERSION:-*}" |
| 34 | echo "Distributor ID: ${DISTRIB_ID:-}" |
| 35 | echo "Description: ${DISTRIB_DESCRIPTION:-}" |
| 36 | echo "Release: ${DISTRIB_RELEASE:-}" |
| 37 | echo "Codename: ${DISTRIB_CODENAME:-}" |
| 38 | |
| 39 | exit 0 |