-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathosdetect.sh
More file actions
executable file
·68 lines (55 loc) · 2.22 KB
/
osdetect.sh
File metadata and controls
executable file
·68 lines (55 loc) · 2.22 KB
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
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#Set OS Detection
arch=$(uname -m)
kernel=$(uname -r)
if [ -n "$(command -v lsb_release)" ]; then
distroname=$(lsb_release -s -d)
elif [ -f "/etc/os-release" ]; then
distroname=$(grep PRETTY_NAME /etc/os-release | sed 's/PRETTY_NAME=//g' | tr -d '="')
elif [ -f "/etc/debian_version" ]; then
distroname="Debian $(cat /etc/debian_version)"
elif [ -f "/etc/redhat-release" ]; then
distroname=$(cat /etc/redhat-release)
else
distroname="$(uname -s) $(uname -r)"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#Various Arch Distros
if [[ "$distroname" =~ "ArcoLinux" ]] || [[ "$distroname" =~ "Arch" ]] || [[ "$distroname" =~ "BlackArch" ]]; then
DISTRO=Arch
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#Raspberry pi
elif [[ "$distroname" =~ "Raspbian" ]]; then
DISTRO=Raspbian
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#Various RedHat Distros
elif [[ "$distroname" =~ "Scientific" ]] || [[ "$distroname" =~ "RedHat" ]] || [[ "$distroname" =~ "CentOS" ]] || [[ "$distroname" =~ "Casjay" ]]; then
DISTRO=RHEL
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#Various Debian Distros
elif [[ "$distroname" =~ "Kali" ]] || [[ "$distroname" =~ "Parrot" ]] || [[ "$distroname" =~ "Debian" ]]; then
DISTRO=Debian
if [[ "$distroname" =~ "Debian" ]]; then
CODENAME=$(lsb_release -a 2>/dev/null | grep Code | sed 's#Codename:##g' | awk '{print $1}')
fi
#Kali
if [[ "$distroname" =~ "Kali" ]]; then
CODENAME=kali
fi
#ParrotSec
if [[ "$distroname" =~ "Parrot" ]]; then
CODENAME=parrot
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#Various Ubuntu Distros
elif [[ "$distroname" =~ "Ubuntu" ]] || [[ "$distroname" =~ "Mint" ]] || [[ "$distroname" =~ "Elementary" ]] || [[ "$distroname" =~ "KDE neon" ]]; then
DISTRO=Ubuntu
CODENAME=$(lsb_release -a 2>/dev/null | grep Code | sed 's#Codename:##g' | awk '{print $1}')
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Fedora
elif [[ "$distroname" =~ "Fedora" ]]; then
DISTRO=Fedora
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##