-
Notifications
You must be signed in to change notification settings - Fork 2
/
b2install-print-os
executable file
·50 lines (45 loc) · 1.79 KB
/
b2install-print-os
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# check for help option
if [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "-?" ]; then
echo
echo "Usage: `basename $0`"
echo
echo "This command determines the operating system name and version and prints them"
echo "in a form that is used to identify the binary version of the Belle II Software."
echo
exit 0
fi
OS_RELEASE_ID="<unknown>"
OS_RELEASE_ID_LIKE="<unknown>"
OS_RELEASE_VERSION="<unknown>"
UBUNTU_CODENAME="<none>"
# If /etc/os-release is present, read system identifier from it
if [ -f /etc/os-release ]; then
OS_RELEASE_ID=`(source /etc/os-release && echo $ID)`
OS_RELEASE_ID_LIKE=`(source /etc/os-release && echo $ID_LIKE)`
if [ "${OS_RELEASE_ID}" = "centos" ] || [ "${OS_RELEASE_ID}" = "rhel" ]; then
OS_RELEASE_ID="el"
elif [ "${OS_RELEASE_ID}" = "scientific" ]; then
OS_RELEASE_ID="el"
elif [ "${OS_RELEASE_ID}" = "rocky" ] || [ "${OS_RELEASE_ID}" = "almalinux" ]; then
OS_RELEASE_ID="el"
elif [[ $OS_RELEASE_ID_LIKE = *ubuntu* ]]; then
OS_RELEASE_ID="ubuntu"
UBUNTU_CODENAME=`(source /etc/os-release && echo $UBUNTU_CODENAME)`
fi
OS_RELEASE_VERSION=`(source /etc/os-release && echo $VERSION_ID | sed 's/\.//g')`
if [ "${OS_RELEASE_ID}" = "el" ]; then
OS_RELEASE_VERSION=`(source /etc/os-release && echo $VERSION_ID | cut -c 1)`
elif [ "${UBUNTU_CODENAME}" = "bionic" ]; then
OS_RELEASE_VERSION=1804
elif [ "${UBUNTU_CODENAME}" = "focal" ]; then
OS_RELEASE_VERSION=2004
elif [ "${UBUNTU_CODENAME}" = "jammy" ]; then
OS_RELEASE_VERSION=2204
fi
# Else if /etc/redhat-release is present, assume SL and read version number from it
elif [ -f /etc/redhat-release ]; then
OS_RELEASE_ID="sl"
OS_RELEASE_VERSION=`(cat /etc/redhat-release | awk -F . '{print $1}' | awk '{print $NF}')`
fi
echo ${OS_RELEASE_ID} ${OS_RELEASE_VERSION}