-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathos.sh
More file actions
50 lines (45 loc) · 999 Bytes
/
os.sh
File metadata and controls
50 lines (45 loc) · 999 Bytes
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
##
# Get the operating system
#
# almalinux, alpine, amzn, antergos, arch, archarm, arcolinux,
# centos, clear-linux-os, clearos,
# debian,
# elementary, endeavouros,
# fedora, freebsd,
# gentoo,
# kali,
# linuxmint,
# mageia, manjaro,
# nixos,
# opensuse, ol,
# pop,
# raspbian, rhel, rocky,
# scientific, slackware, sles,
# ubuntu,
# virtuozzo
#
function os() {
if [ "$(uname -s)" == 'FreeBSD' ]; then
echo 'freebsd'
elif [ -f '/etc/os-release' ]; then
local DISTRO="$(egrep '^ID=' /etc/os-release | sed 's:ID=::')"
if [[ "$DISTRO" =~ '"' ]]; then
# Strip quotes around the OS name
DISTRO="$(echo "$DISTRO" | sed 's:"::g')"
fi
# Cleanup a few known distro names
if [ "$DISTRO" == "manjaro-arm" ]; then
# Manjaro on ARM
DISTRO="manjaro"
elif [ "$DISTRO" == "opensuse-leap" ]; then
# OpenSuSE Leap 15.x
DISTRO="opensuse"
elif [ "$DISTRO" == "sles_sap" ]; then
# SuSE Enterprise SAP 12.x
DISTRO="sles"
fi
echo "$DISTRO"
else
echo 'unknown'
fi
}