Skip to content

Commit 39d7888

Browse files
authored
Update combined.sh
Updated for better Fedora support, plus Bluefin and Bazzite support.
1 parent f0a07f7 commit 39d7888

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

log-helper/combined.sh

+27-28
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@ focused_summary_file="focused_summary_temp.txt"
99
BOLD='\033[1m'
1010
RESET='\033[0m'
1111

12-
1312
# Ensure necessary packages are installed based on the operating system
1413
if [ -f /etc/os-release ]; then
15-
# Extract OS details using grep
1614
OS_ID=$(grep ^ID= /etc/os-release | cut -d'=' -f2 | tr -d '"')
1715
OS_VERSION_ID=$(grep ^VERSION_ID= /etc/os-release | cut -d'=' -f2 | tr -d '"')
1816

1917
# Check and install required packages based on the distribution
2018
case "$OS_ID" in
2119
ubuntu)
2220
sudo apt-get update -qq
23-
sudo apt-get install -y -qq pciutils iw inxi speedtest-cli lsb-release || { echo "${BOLD}Package installation failed on Ubuntu.${RESET}"; exit 1; }
21+
sudo apt-get install -y -qq pciutils iw inxi || { echo "${BOLD}Package installation failed on Ubuntu.${RESET}"; exit 1; }
2422
;;
2523
fedora)
26-
sudo dnf install -y -q pciutils iw inxi speedtest-cli redhat-lsb-core || { echo "${BOLD}Package installation failed on Fedora.${RESET}"; exit 1; }
24+
sudo dnf install -y -q pciutils iw inxi || { echo "${BOLD}Package installation failed on Fedora.${RESET}"; exit 1; }
25+
;;
26+
bluefin|bazzite)
27+
# Do not install any packages on these distributions
28+
# Just skip installation.
2729
;;
2830
*)
2931
echo "${BOLD}Unsupported distribution: $OS_ID${RESET}"
@@ -35,7 +37,6 @@ else
3537
exit 1
3638
fi
3739

38-
3940
# Function to display progress bar
4041
show_progress() {
4142
local width=50
@@ -61,7 +62,15 @@ get_system_info() {
6162
echo "" >> "$output_file"
6263
echo "Kernel version: $(uname -r)" >> "$output_file"
6364
echo "Desktop Environment: $XDG_CURRENT_DESKTOP" >> "$output_file"
64-
echo "Distribution: $(lsb_release -d | cut -f2)" >> "$output_file"
65+
66+
# For distribution, read from /etc/os-release
67+
if [ -f /etc/os-release ]; then
68+
OS_NAME=$(grep PRETTY_NAME /etc/os-release | cut -d= -f2 | tr -d '"')
69+
echo "Distribution: $OS_NAME" >> "$output_file"
70+
else
71+
echo "Distribution: Unknown (no /etc/os-release)" >> "$output_file"
72+
fi
73+
6574
echo "BIOS Version: $(sudo dmidecode -s bios-version)" >> "$output_file"
6675
echo "" >> "$output_file"
6776
}
@@ -70,8 +79,7 @@ get_system_info() {
7079
process_logs() {
7180
local start_time=$1
7281
local end_time=$2
73-
74-
# Convert start and end times to seconds since epoch for comparison
82+
7583
local start_seconds=$(date -d "$start_time" +%s)
7684
local end_seconds=$(date -d "$end_time" +%s)
7785

@@ -103,11 +111,9 @@ process_logs() {
103111
done
104112

105113
echo -e "\nDmesg processing complete."
106-
107114
echo "" >> "$output_file"
108115

109116
# Create a header for journalctl section with spacing
110-
echo "" >> "$output_file"
111117
echo "===== journalctl output starts =====" >> "$output_file"
112118
echo "" >> "$output_file"
113119

@@ -131,7 +137,7 @@ process_logs() {
131137
# Function to add summaries to the file
132138
add_summaries() {
133139
local file=$1
134-
140+
135141
# Add focused summary section to the end of the output file
136142
echo "" >> "$file"
137143
echo "===== Focused Summary of Potential Issues =====" >> "$file"
@@ -159,7 +165,10 @@ add_summaries() {
159165
echo "" >> "$file"
160166
}
161167

168+
########################################
162169
# Main script starts here
170+
########################################
171+
163172
echo "Choose an option:"
164173
echo "1. Last x minutes"
165174
echo "2. Last 24 hours"
@@ -194,22 +203,7 @@ case $choice in
194203
add_summaries "$output_file"
195204
;;
196205
4)
197-
echo "Looking for file called combined_log.txt in home directory..."
198-
if [ ! -f "$output_file" ]; then
199-
echo "File not found: $output_file"
200-
exit 1
201-
fi
202-
echo "File found. Proceeding with filtering options."
203-
;;
204-
*)
205-
echo "Invalid choice"
206-
exit 1
207-
;;
208-
esac
209-
210-
if [ "$choice" == "4" ]; then
211206
echo "Looking for file called combined_log.txt in current directory..."
212-
output_file="$(pwd)/combined_log.txt" # Change to current directory
213207
if [ ! -f "$output_file" ]; then
214208
echo "File not found: $output_file"
215209
exit 1
@@ -248,8 +242,13 @@ if [ "$choice" == "4" ]; then
248242
echo -e "\n${BOLD}Filtered log saved in $filtered_output_file${RESET}"
249243
line_count=$(wc -l < "$filtered_output_file")
250244
echo -e "${BOLD}Total lines in filtered output: $line_count${RESET}"
251-
fi
245+
;;
246+
*)
247+
echo "Invalid choice"
248+
exit 1
249+
;;
250+
esac
252251

253-
# Remove temporary files
252+
# Clean up temporary files
254253
[ -f "$summary_file" ] && rm "$summary_file"
255254
[ -f "$focused_summary_file" ] && rm "$focused_summary_file"

0 commit comments

Comments
 (0)