-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysinfo-collector.sh
More file actions
244 lines (212 loc) · 6.66 KB
/
sysinfo-collector.sh
File metadata and controls
244 lines (212 loc) · 6.66 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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
# System Information Collector
# Modular, interactive or non-interactive with options.
# Can save locally or upload via eos-sendlog.
SCRIPT_VERSION="1.7"
timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
outfile="/tmp/sysreport-$timestamp.txt"
###########################
### HELP ##################
###########################
show_help() {
echo "System Information Collector v$SCRIPT_VERSION"
echo
echo "Usage: $0 [options]"
echo
echo "Without options, script runs interactively."
echo "With options, script runs non-interactively."
echo
echo "Information collection options:"
echo " -nv, --nvidia Collect NVIDIA information"
echo " -in, --intel Collect Intel GPU information"
echo " -bc, --broadcom Collect Broadcom WiFi information"
echo " -inst,--installer Collect EndeavourOS installer log"
echo " -part,--partitions Collect partitions and fstab info"
echo " -boot,--bootlog Collect boot log (journalctl -b -0)"
echo " -pkg, --packages Collect installed packages list"
echo " -custom, --custom Collect custom log (placeholder)"
echo " -all, --all Collect everything"
echo
echo "Output options:"
echo " --local Save locally only, do not upload"
echo " --pastebin Upload automatically via eos-sendlog"
echo " --help Show this help"
exit 0
}
[[ "$1" == "--help" ]] && show_help
###########################
### FLAGS #################
###########################
DO_NVIDIA=false
DO_INTEL=false
DO_BROADCOM=false
DO_INSTALLER=false
DO_PARTITIONS=false
DO_BOOT=false
DO_PACKAGES=false
DO_CUSTOM=false
FORCE_LOCAL=false
FORCE_PASTEBIN=false
###########################
### PARSE OPTIONS #########
###########################
if [[ $# -gt 0 ]]; then
INTERACTIVE=false
while [[ $# -gt 0 ]]; do
case "$1" in
-nv|--nvidia) DO_NVIDIA=true ;;
-in|--intel) DO_INTEL=true ;;
-bc|--broadcom) DO_BROADCOM=true ;;
-inst|--installer) DO_INSTALLER=true ;;
-part|--partitions) DO_PARTITIONS=true ;;
-boot|--bootlog) DO_BOOT=true ;;
-pkg|--packages) DO_PACKAGES=true ;;
-custom|--custom) DO_CUSTOM=true ;;
-all|--all)
DO_NVIDIA=true
DO_INTEL=true
DO_BROADCOM=true
DO_INSTALLER=true
DO_PARTITIONS=true
DO_BOOT=true
DO_PACKAGES=true
DO_CUSTOM=true
;;
--local) FORCE_LOCAL=true ;;
--pastebin) FORCE_PASTEBIN=true ;;
--help) show_help ;;
*)
echo "Unknown option: $1"
echo "Use --help to see valid options"
exit 1
;;
esac
shift
done
else
INTERACTIVE=true
fi
###########################
### SUPPORT FUNCTIONS #####
###########################
# Ask user (interactive only)
ask() {
if ! $INTERACTIVE; then return 1; fi # <-- non-interactive: always false
read -rp "$1 (y/n): " ans
[[ "$ans" =~ ^[Yy]$ ]]
}
add_header() {
echo -e "\n\n===== $1 =====" >> "$outfile"
}
###########################
### REPORT HEADER #########
###########################
{
echo "=== System Information Report ==="
echo "Generated: $timestamp"
echo "Hostname : $(hostname)"
echo "Kernel : $(uname -r)"
echo "User : $USER"
echo "Script : sysinfo-collector v$SCRIPT_VERSION"
echo "====================================="
} >> "$outfile"
###########################
### COLLECTION TASKS ######
###########################
# GPU info (inxi -Gaz) only once
if [ "$DO_NVIDIA" = true ] || [ "$DO_INTEL" = true ] || ask "Collect GPU information?"; then
add_header "GPU Info: inxi -Gaz"
inxi -Gaz >> "$outfile" 2>&1
fi
# NVIDIA packages
if [ "$DO_NVIDIA" = true ]; then
add_header "NVIDIA: pacman -Qs nvidia"
pacman -Qs nvidia >> "$outfile" 2>&1
fi
# Intel packages
if [ "$DO_INTEL" = true ]; then
add_header "Intel: pacman -Qs intel"
pacman -Qs intel >> "$outfile" 2>&1
fi
# Broadcom
if [ "$DO_BROADCOM" = true ] || ask "Collect Broadcom WiFi information?"; then
add_header "Broadcom: inxi -Naz"
inxi -Naz >> "$outfile" 2>&1
add_header "Broadcom: pacman -Qs broadcom"
pacman -Qs broadcom >> "$outfile" 2>&1
fi
# Installer log
if [ "$DO_INSTALLER" = true ] || ask "Collect EndeavourOS installer log? (requires sudo)"; then
add_header "Installer Log"
if [ -f /var/log/endeavour-install.log ]; then
# Use the system log if it exists
sudo cat /var/log/endeavour-install.log >> "$outfile" 2>&1
elif [ -f /home/liveuser/endeavour-install.log ]; then
# Fallback to user's log if system log doesn't exist
cat /home/liveuser/endeavour-install.log >> "$outfile" 2>&1
else
echo "No installer log found." >> "$outfile"
fi
fi
# Partition info
if [ "$DO_PARTITIONS" = true ] || ask "Collect partition info? (requires sudo)"; then
add_header "Partition Info: fdisk -l"
sudo fdisk -l >> "$outfile" 2>&1
add_header "Partition Info: /etc/fstab"
cat /etc/fstab >> "$outfile" 2>&1
fi
# Boot log
if [ "$DO_BOOT" = true ] || ask "Collect boot log (journalctl -b -0)?"; then
add_header "Boot Log: journalctl -b -0"
journalctl -b -0 >> "$outfile" 2>&1
fi
# Installed packages
if [ "$DO_PACKAGES" = true ] || ask "Collect installed packages list?"; then
add_header "Installed Packages: pacman -Qq"
pacman -Qq >> "$outfile" 2>&1
fi
# CUSTOM LOG PLACEHOLDER
collect_custom_log() {
# Replace this with your actual commands
# Example:
# add_header "Custom Log: /path/to/custom.log"
# cat /path/to/custom.log >> "$outfile" 2>&1
:
}
if [ "$DO_CUSTOM" = true ] || ask "Collect custom log?"; then
collect_custom_log
fi
###########################
### OUTPUT HANDLING #######
###########################
echo
echo "=== Report creation finished ==="
echo "File saved at: $outfile"
echo
# Non-interactive forced modes
if $FORCE_LOCAL; then
echo "--local specified: storing file locally."
echo "$outfile"
exit 0
fi
if $FORCE_PASTEBIN; then
echo "--pastebin specified: uploading via eos-sendlog..."
result=$(cat "$outfile" | eos-sendlog 2>&1)
echo "Upload result:"
echo "$result"
exit 0
fi
# Interactive upload prompt
if $INTERACTIVE; then
read -rp "Upload via eos-sendlog instead of saving locally? (y/n): " upload
if [[ "$upload" =~ ^[Yy]$ ]]; then
echo "Uploading..."
result=$(cat "$outfile" | eos-sendlog 2>&1)
echo "Upload result:"
echo "$result"
exit 0
fi
fi
echo "Report stored locally at:"
echo "$outfile"
echo "Done."