-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoscheck.sh
64 lines (59 loc) · 1.46 KB
/
oscheck.sh
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
#!/bin/bash
set -e
if [[ $EUID -ne 0 ]]; then
echo "* This script must be executed with root privileges (sudo)." 1>&2
exit 1
fi
# check for curl
if ! [ -x "$(command -v curl)" ]; then
echo "* curl is required in order for this script to work."
echo "* install using apt (Debian and derivatives) or yum/dnf (CentOS)"
exit 1
fi
output() {
echo -e "\033[0;34m- ${1} \033[0m"
}
ask() {
GC='\033[0;32m'
NC='\033[0m'
echo -e -n "${GC}- ${1}${NC} "
}
error() {
RC='\033[0;31m'
NC='\033[0m'
echo -e "${RC}ERROR: ${1}${NC}"
}
detect_distro() {
if type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si | awk '{print tolower($0)}')
OS_VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$(echo "$DISTRIB_ID" | awk '{print tolower($0)}')
OS_VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS="debian"
OS_VER=$(cat /etc/debian_version)
fi
OS=$(echo "$OS" | awk '{print tolower($0)}')
OS_VER_MAJOR=$(echo "$OS_VER" | cut -d. -f1)
}
os_check() {
detect_distro
if [[ $OS == debian ]]; then
echo -e "\033[0;34m- Found Current OS: $OS\033[0m"
elif [[ $OS == ubuntu ]]; then
output "Found Current OS: $OS"
else
error "Unsupported OS!"
exit 1
fi
}
user_redirect() {
bash <(curl -s https://raw.githubusercontent.com/unknownpersonog/PufferXcript)
}
os_check
user_redirect