source: CMT/HEAD/mgr/cmt_linux_version.sh

Last change on this file was 499, checked in by rybkin, 15 years ago

See C.L. 394

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1
2# Determine the Linux distribution and version that is being run.
3#
4
5export LC_ALL=C
6# Check for GNU/Linux distributions
7if [ -f /etc/SuSE-release ]; then
8    DISTRIBUTION="suse"
9    VERSION=`sed  -n '/VERSION/{s#[^0-9]##gp;q}' /etc/SuSE-release`
10elif [ -f /etc/UnitedLinux-release ]; then
11    DISTRIBUTION="united"
12    VERSION=`cat /etc/UnitedLinux-release`
13elif [ -f /etc/debian_version ]; then
14    DISTRIBUTION="debian"
15    VERSION=`cat /etc/debian_version`
16    if [ ${VERSION} = "testing/unstable" ]; then
17        # The debian testing/unstable version must be translated into
18        # a numeric version number, but no number makes sense so just
19        # remove the version all together.
20        VERSION=""
21    fi
22elif [ -f /etc/redhat-release ]; then
23    read a </etc/redhat-release
24    case "$a" in
25        Red*Hat*Enterprise*Linux*)
26            DISTRIBUTION=rhel
27            ;;
28        Red*Hat*Linux*)
29            DISTRIBUTION=rh
30            ;;
31        CERN*E*Linux*)
32            DISTRIBUTION=cel
33            ;;
34        Scientific*Linux*CERN*)
35            DISTRIBUTION=slc
36            ;;
37        Scientific*Linux*)
38            DISTRIBUTION=sl
39            ;;
40        Fedora*)
41            DISTRIBUTION=fedora
42            ;;
43        *)
44            DISTRIBUTION=slc
45            ;;
46    esac
47    VERSION=""
48    release=
49    for w in `echo $a`; do
50        case "$w" in
51            release)
52                release=y
53                ;;
54            *)
55                if [ "$release" ]; then
56                    VERSION=$w
57                    release=
58                fi
59                ;;
60        esac
61    done
62#     while [ -n "$a" ]; do
63#       t="${a#?}"              # all but first char of $a
64#       c=${a%"${t}"}           # first char of $a
65#       a="${t}"                # remove first char from $a
66#       case "$c" in
67#           [0-9])
68#           VERSION="${VERSION}${c}"
69#           ;;
70#       esac
71#     done
72    case "$VERSION" in
73        70|71|72)
74            VERSION=73
75            ;;
76    esac
77    [ "$VERSION" ] || VERSION='00'
78else
79    DISTRIBUTION="unknown"
80    VERSION='00'
81fi
82
83echo ${DISTRIBUTION}-${VERSION}
Note: See TracBrowser for help on using the repository browser.