-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathZeus.sh
More file actions
97 lines (83 loc) · 2 KB
/
Zeus.sh
File metadata and controls
97 lines (83 loc) · 2 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
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
#!/usr/bin/env bash
###
# @Author: Cloudflying
# @Date: 2026-02-03 15:10:05
# @LastEditTime: 2026-02-03 15:54:31
# @LastEditors: Cloudflying
# @Description: Linux && macOS Tools (Bench)
###
ROOT_PATH="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
_red() {
printf '\033[1;31;31m%b\033[0m' "$1"
}
_green() {
printf '\033[1;31;32m%b\033[0m' "$1"
}
_yellow() {
printf '\033[1;31;33m%b\033[0m' "$1"
}
_info() {
_green "[Info] "
printf -- "%s" "$1"
printf "\n"
}
_warn() {
_yellow "[Warning] "
printf -- "%s" "$1"
printf "\n"
}
_error() {
_red "[Error] "
printf -- "%s" "$1"
printf "\n"
exit 1
}
get_os_info()
{
if [[ -f /etc/os-release ]]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [[ -f /etc/lsb-release ]]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
else
_error "Unknown OS"
fi
}
get_cpu_info()
{
if [[ "$(uname -s)" == 'Linux' ]]; then
if [[ -f "/proc/cpuinfo" ]]; then
CPU_MODEL=$(grep "model name" /proc/cpuinfo | head -n 1 | awk '{print substr($0, index($0,$4))}')
CPU_CORES=$(grep -c ^processor /proc/cpuinfo)
CPU_MHZ=$(grep "cpu MHz" /proc/cpuinfo | head -n 1 | awk '{print substr($0, index($0,$4))}')
CPU_CACHE=$(grep "cache size" /proc/cpuinfo | head -n 1 | awk '{print substr($0, index($0,$4))}')
fi
fi
}
is_wsl()
{
case "$(uname -r)" in
*microsoft*) echo 0 ;;
*) echo 1 ;;
esac
}
print_system_info()
{
if [[ "$(is_wsl)" ]]; then
DISTRO_SUFFIX="On Windows $(uname -m) (WSL)"
fi
echo "$(_green "Distro :")" "${OS} ${DISTRO_SUFFIX}"
echo "$(_green "Kernel :")" "$(uname -r)"
echo "$(_green "CPU :")" "${CPU_MODEL}" "(${CPU_CORES} Cores @ ${CPU_MHZ}MHz)"
}
get_os_info
get_cpu_info
print_system_info