-
Notifications
You must be signed in to change notification settings - Fork 25
/
os-version-info
executable file
·121 lines (116 loc) · 2.55 KB
/
os-version-info
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
set -euf -o pipefail
out () { printf %s\\n "$*" ; }
##
# Show the operating system version information.
#
# Syntax:
#
# os-version-info
#
# Example on OSX:
#
# $ os-version-info
#
# uname -a
# Darwin MacBook-Pro.local 14.4.0 Darwin Kernel Version 14.4.0: Tue May 5 14:17:52 PDT 2015; root:xnu-2782.30.4~3/RELEASE_X86_64 x86_64
#
# sw_vers
# ProductName:Mac OS X
# ProductVersion:10.10.4
# BuildVersion:14E17e
#
# Example on Ubuntu:
#
# $ os-version-info
#
# uname -a
# Linux my-ubuntu-lucid 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 x86_64 GNU/Linux
#
# lsb_release -a
# Distributor ID:Ubuntu
# Description:Ubuntu 10.04.4 LTS
# Release:10.04
# Codename:lucid
#
# Contact: Joel Parker Henderson ([email protected])
# License: GPL
# Updated: 2015-06-21
##
##
# Unix name on Linux, BSD, etc.
#
# Example output on Ubuntu:
#
# uname -a
# Linux my-example-lucid 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 x86_64 GNU/Linux
#
# Example output on RedHat:
#
# uname -a
# Linux my.example.com 2.6.9-89.31.1.EL #1 Mon Oct 4 21:42:07 EDT 2010 i686 athlon i386 GNU/Linux
#
# Example output on OSX:
#
# uname -a
# Darwin MacBook-Pro.local 14.4.0 Darwin Kernel Version 14.4.0: Tue May 5 14:17:52 PDT 2015; root:xnu-2782.30.4~3/RELEASE_X86_64 x86_64
##
if command -v uname >/dev/null 2>&1; then
out; out 'uname -a'
uname -a
fi
##
# Linux Standard Base (LSB)
#
# Example output:
#
# lsb_release -a
# Distributor ID:Ubuntu
# Description:Ubuntu 10.04.4 LTS
# Release:10.04
# Codename:lucid
##
if command -v lsb_release >/dev/null 2>&1; then
out; out 'lsb_release -a'
lsb_release -a
fi
##
# Linux RedHat
#
# Example output:
#
# cat /etc/redhat-release
# Red Hat Enterprise Linux ES release 4 (Nahant Update 9)
#
# cat /proc/version
# Linux version 2.6.9-89.31.1.EL ([email protected]) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-11)) #1 Mon Oct 4 21:42:07 EDT 2010
#
# cat /etc/issue.net
# Red Hat Enterprise Linux ES release 4 (Nahant Update 9)
# Kernel \r on an \m
##
if [[ -e /etc/redhat-release ]]; then
for file in /etc/redhat-release /proc/version /etc/issue.net
do
if [[ -e $file ]]
then
out ''
out "cat $file"
cat $file
fi;
done
fi
##
# OSX
#
# Example output:
#
# sw_vers
# ProductName:Mac OS X
# ProductVersion:10.10.4
# BuildVersion:14E17e
##
if command -v sw_vers >/dev/null 2>&1; then
out; out 'sw_vers'
sw_vers
fi