-
Notifications
You must be signed in to change notification settings - Fork 9
/
debug
executable file
·176 lines (121 loc) · 3.85 KB
/
debug
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/bin/env zsh
# macos-scripts/debug
# debug
# Print some debug info about the current system
set -uo pipefail
# -u prevent using undefined variables
# -o pipefail force pipelines to fail on first non-zero status code
IFS=$'\n\t'
# Set Internal Field Separator to newlines and tabs
# This makes bash consider newlines and tabs as separating words
# See: http://redsymbol.net/articles/unofficial-bash-strict-mode/
### UTILITY FUNCTIONS ###
# ctrl_c
# usage
function ctrl_c {
# shellcheck disable=SC2317
echo -e "\\n[❌] ${USER} has chosen to quit!"
# shellcheck disable=SC2317
exit 1
}
function usage {
echo -e "\\n Print some debug info about the current system"
echo -e " ./debug | pbcopy\\n"
exit 0
}
### END UTILITY FUNCTIONS ###
function timestamp {
echo "Timestamp: $(date)"
}
function version_info {
build=$(sw_vers | grep "Build" | awk '{print $2}')
version=$(sw_vers | grep "ProductVersion" | awk '{print $2}')
echo "macOS: ${version} (Build: ${build})"
}
function is_admin {
if groups | grep -q 'admin'; then
echo "Account Type: Administrator"
else
echo "Account Type: Standard User"
fi
}
function hardware_info {
hardware_data=$(system_profiler SPHardwareDataType)
model=$(echo "${hardware_data}" | grep "Identifier" | awk '{print $3}')
ram=$(echo "${hardware_data}" | grep "Memory: " | awk -F ':' '{print $2}')
processor_name=$(echo "${hardware_data}" | grep "Processor Name: " | awk -F ':' '{print $2}')
processor_speed=$(echo "${hardware_data}" | grep "Processor Speed: " | awk -F ':' '{print $2}')
echo "Model: ${model}"
echo "RAM: ${ram}"
echo "Processor:
${processor_name}
${processor_speed}"
}
function time_stats {
last_reboot=$(last reboot | head -1 | awk -F " " '{print $2}')
uptime=$(uptime | awk -F ',' '{print $1}' | awk -F 'up' '{print $2}')
echo "Boot time: ${last_reboot}"
echo "Uptime: ${uptime}"
}
function filesystem_info {
spotlight_status=$(mdutil -s / | grep 'Indexing' | awk '{print $2}' | tr -d '.')
fs_type=$(diskutil info / | grep 'Type (Bundle):' | awk '{print $3}')
echo "File System Type: ${fs_type}"
echo "Spotlight status for '/': ${spotlight_status}"
}
function security_info {
gatekeeper_status=$(spctl --status | awk '{print $2}')
kext_loading_stats=$(spctl kext-consent status | awk -F ': ' '{print $2}')
sip_status=$(csrutil status | awk -F ': ' '{print $2}' | tr -d '.')
filevault_status=$(fdesetup status | awk '{print $3}' | tr -d '.')
echo "Gatekeeper Status: ${gatekeeper_status}"
echo "Kernel Extension User Consent: ${kext_loading_stats}"
echo "System Integrity Protection: ${sip_status}"
echo "FileVault status: ${filevault_status}"
# if system_profiler SPiBridgeDataType | grep 'Model Name:' | grep -q 'T2'; then
# :
# else
# if /usr/libexec/firmwarecheckers/eficheck/eficheck --integrity-check >/dev/null 2>&1; then
# echo "EFI Firmware: "
# fi
# fi
}
function full_disk_access_check {
if [ -r "/$HOME/Library/Mail" ]; then
echo "Terminal Full Disk Access: Enabled"
else
echo "Terminal Full Disk Access: Disabled"
fi
}
function launchd_stuff {
echo "User Launchd Processes:"
launchctl list | grep -v 'com.apple' | tail -n +2 | awk '{print $3}'
}
function third_party_kexts {
echo "Third party Kernel Extensions:"
kextstat | grep -v 'com.apple' | tail -1 | awk '{print $6}'
}
function main {
trap ctrl_c SIGINT
# Detect and react to the user hitting CTRL + C
declare -r arg=${1:-""}
case "${arg}" in
usage|help|-h|--help|🤷♂️|🤷♀️|"¯\_(ツ)_/¯")
usage
;;
*)
timestamp
version_info
is_admin
hardware_info
time_stats
filesystem_info
security_info
full_disk_access_check
launchd_stuff
third_party_kexts
exit 0
;;
esac
}
main "$@"