forked from StarLabsLtd/logs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
star-logs-arch
executable file
·112 lines (91 loc) · 4.99 KB
/
star-logs-arch
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
#!/bin/bash
function splash() {
action="$1"
# clear
cat << "EOF"
╔═════════════════════════════════════════════════════════════════════════════╗
║ ║
║ ██╗ ██████╗ ██████╗ ███████╗ ║
║ ██║ ██╔═══██╗██╔════╝ ██╔════╝ ║
║ ██║ ██║ ██║██║ ███╗███████╗ ║
║ ██║ ██║ ██║██║ ██║╚════██║ ║
║ ███████╗╚██████╔╝╚██████╔╝███████║ ║
║ ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ║
╚═════════════════════════════════════════════════════════════════════════════╝
EOF
printf "╔═════════════════════════════════════════════════════════════════════════════╗\n"
printf "%-79s %s\n" "║ Gathering logs: $(cat /sys/class/dmi/id/product_name)" "║ "
printf "╚═════════════════════════════════════════════════════════════════════════════╝\n\n"
}
splash "Star Labs Diagnostics"
red=$(tput setaf 1)
green=$(tput setaf 2)
normal=$(tput sgr0)
if [ "$EUID" -ne 0 ];then
printf "\nStar-Logs requires root priveldges. Please type in:\n\n"
printf "%s\n\n" "${green}sudo star-logs"
exit
fi
if ! fwupdmgr get-updates 2>&1 | grep -q 'No updates'; then
printf \
"Your firmware is not up to date. Updating the firmware may\n\
resolve the issue you are experiencing.\n\n\
Please see the below guide on how to update your firmware.\n\n\
https://starlabsltd.github.io/firmware/methods\n"
fi
log_dir="/tmp/$(cat /sys/class/dmi/id/product_name)_$(date '+%Y-%m-%d_%H-%M-%S')"
mkdir -p "$log_dir"
printf "%-35s %s" "${normal}Journalctl:"
journalctl -r --since "3 days ago" &> "$log_dir/journalctl.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Boot log:"
journalctl -r --list-boots &> "$log_dir/boot.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Dmesg:"
dmesg &> "$log_dir/dmesg.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Firmware information:"
fwupdmgr --version &> "$log_dir/fwupd.txt"
fwupdmgr get-devices --show-all-devices --verbose &> "$log_dir/fwupd-devices.txt"
fwupdtool get-devices --plugins flashrom --verbose &> "$log_dir/fwupd-flashrom.txt"
fwupdmgr security --force &> "$log_dir/fwupd-security.txt"
dmidecode &> "$log_dir/dmi.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Distribution information:"
lsb_release -a &> "$log_dir/distro.txt"
uname -r &> "$log_dir/kernel.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Battery information:"
upower -i /org/freedesktop/UPower/devices/battery_BAT0 &> "$log_dir/battery.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Installed programs:"
pacman -Qe &> "$log_dir/installed.txt"
pacman -Qu &> "$log_dir/upgradeable.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Kernel config:"
mkdir "$log_dir/modprobe"
for f in /etc/modprobe.d/*; do
cat "$f" &> "$log_dir/modprobe/$(echo $f | cut -d '/' -f4)"
done
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}PCI devices:"
lspci -vvvnnnxxx &> "$log_dir/pci.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Getting audio codec:"
cat /proc/asound/card0/codec#0 &> "$log_dir/codec.txt"
printf "%s\n" "${green}✔"
if [[ $(cat /sys/class/dmi/id/bios_vendor) == "coreboot" ]]; then
printf "%-35s %s" "${normal}NVRAM:"
nvramtool -a &> "$log_dir/nvram.txt"
printf "%s\n" "${green}✔"
fi
if command -v snap &> /dev/null; then
printf "%-35s %s" "${normal}Installed snaps:"
snap list &> "$log_dir/snap.txt"
printf "%s\n" "${green}✔"
fi
pushd "$log_dir" > /dev/null || exit
tar -zcvf "/home/$SUDO_USER/Downloads/$(echo $log_dir | cut -d '/' -f3).zip" . 2&> /dev/null
popd > /dev/null || exit
chown "$SUDO_USER:$SUDO_USER" "/home/$SUDO_USER/Downloads/$(echo $log_dir | cut -d '/' -f3).zip"
printf "\n${normal}Logs have been saved to ${green}~/Downloads/$(echo $log_dir | cut -d '/' -f3).zip\n"