-
Notifications
You must be signed in to change notification settings - Fork 2
/
star-logs-opensuse
executable file
·128 lines (106 loc) · 5.51 KB
/
star-logs-opensuse
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
#!/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
# Check software is up to date
if ! [[ "$(zypper list-updates | grep 'No updates found')" ]]; then
printf "Your software is not up to date. Updating the software may
resolve the issue you are experiencing. Would you like to
update your software now?\n\n"
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 --json &> "$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:"
cat /etc/os-release &> "$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:"
zypper search -i &> "$log_dir/installed.txt"
zypper list-updates &> "$log_dir/upgradeable.txt"
printf "%s\n" "${green}✔"
printf "%-35s %s" "${normal}Package sources:"
mkdir -p "$log_dir/repo"
for f in /etc/zypp/repos.d/*.repo; do
cat "$f" &> "$log_dir/repo/$(echo $f | cut -d '/' -f5)"
done
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
if ! [ -x "$(command -v nvramtool)" ]; then
zypper -n install coreboot-utils
fi
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
zip -r "/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"