From d1bb77802241aa57662fdbca476588aaf82a9218 Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:11:28 +0100 Subject: [PATCH 01/11] Initial --- .../script/diagnostics/util_exporter.sh | 1 + .../script/diagnostics/util_netcheck.sh | 391 ++++++++++++++++++ .../script/diagnostics/util_snapshot.sh | 2 +- 3 files changed, 393 insertions(+), 1 deletion(-) create mode 100644 static/build/.tmp_update/script/diagnostics/util_netcheck.sh diff --git a/static/build/.tmp_update/script/diagnostics/util_exporter.sh b/static/build/.tmp_update/script/diagnostics/util_exporter.sh index 3ab44fda3..e88cad0c8 100644 --- a/static/build/.tmp_update/script/diagnostics/util_exporter.sh +++ b/static/build/.tmp_update/script/diagnostics/util_exporter.sh @@ -26,6 +26,7 @@ move_runtime_logs() { exporter() { log "Exporting and archiving logs" + rm -rf $filename move_runtime_logs sync sleep 1 diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh new file mode 100644 index 000000000..3e8c17769 --- /dev/null +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -0,0 +1,391 @@ +#!/bin/sh + +# This script will run a suite of network checks from the device, the captured data is mostly response codes from services and ping replies +# It will however pull dmesg, which may contain the users WiFi SSID. Be cautious as to where you ask the user to upload this. + +menulabel="Network log snapshot" +tooltip="Check common websites/services for access \n and export the logs to SD:log_export.7z" + +################## +## SETUP ## +################## +SDDIR="/mnt/SDCARD" +SYSDIR="${SDDIR}/.tmp_update" +LOGDIR="${SYSDIR}/logs" +DIAGSDIR="${SYSDIR}/script/diagnostics" +THEME_TEST_ASSET="https://raw.githubusercontent.com/OnionUI/Themes/main/release/M%20by%20tenlevels.zip" +PORTS_TEST_ASSET="https://github.com/OnionUI/Ports-Collection/releases/latest/download/Sonic.Mania.7z" +PICO_BBS_ASSET="https://www.lexaloffle.com/bbs/cpost_lister3.php?cat=7" +RA_CFG="/mnt/SDCARD/RetroArch/.retroarch/retroarch.cfg" +RA_URL="https://retroachievements.org" + +################## +## LOGGING FUNCTION ## +################## + +logfile=util_netcheck +. "${SYSDIR}/script/log.sh" +program=$(basename "$0" .sh) + +log_message() { + local message="$(date +"%Y-%m-%d %H:%M:%S") - $1" + echo -e "$message" >> "${LOGDIR}/network_check.log" + echo -e "$message" # for console +} + +section_header() { + local header=$1 + log_message "======== $header ========" +} + +################## +## CHECKING ## +################## + +ping_success=0 +ping_total=0 +website_success=0 +website_total=0 +download_success=0 +download_total=0 + +################## +## Util functions ## +################## + +check_usb_devices() { + local device_count=$(lsusb | wc -l) + device_count=$((device_count)) + + if [ "$device_count" -ge 3 ]; then + log_message "Check successful: Found $device_count USB devices connected." + else + log_message "Check failed: Only $device_count USB devices found. Third USB device missing, possible WiFi chip failure - does WiFi work?" + fi +} + +perform_ping() { + local host=$1 + local service=$2 + section_header "Ping Test for $service" + log_message "Starting ping test for $service: $host" + ping_total=$((ping_total + 1)) + if ping -c 1 -W 2 $host > /dev/null 2>&1; then + log_message "Ping to $host ($service) successful. \n" + ping_success=$((ping_success + 1)) + return 0 + else + log_message "Ping to $host ($service) failed. \n" + return 1 + fi +} + +check_website() { + local url=$1 + website_total=$((website_total + 1)) + section_header "Website Availability Check" + log_message "Checking website availability: $url" + if wget -q --no-check-certificate --spider $url; then + log_message "Website $url is up.\n" + website_success=$((website_success + 1)) + return 0 + else + log_message "Website $url is down.\n" + return 1 + fi +} + +test_download() { + local url=$1 + download_total=$((download_total + 1)) + log_message "Testing download from: $url" + # check the response trying to download assets from $url + # 200 is good, anything else not so good. + # doesn't actually download the asset, just attempts + local status=$(curl -o /dev/null -s -w "%{http_code}" -L --head --insecure "$url") + if [ "$status" -eq 200 ]; then + log_message "Download test for $url was successful. Status code: $status \n" + download_success=$((download_success + 1)) + return 0 + else + log_message "Download test for $url failed with status code: $status \n" + return 1 + fi +} + +test_dns_resolution() { + local dns_test_host="google.com" + if nslookup "$dns_test_host" > /dev/null 2>&1; then + log_message "DNS resolution test for $dns_test_host successful. \n" + return 0 + else + log_message "DNS resolution test for $dns_test_host failed. \n" + return 1 + fi +} + +check_firmware_for_dns_issue() { + section_header "Firmware DNS Check" + local version + version=$(/etc/fw_printenv miyoo_version) + if [ "$version" = "202303021817" ]; then + log_message "DNS Failure will occur due to firmware version, update your firmware. \n" + return 0 + else + log_message "Firmware supports DNS, testing...\n" + test_dns_resolution + return 1 + fi +} + +pull_common_logs() { + ifconfig -a >> "${LOGDIR}/network_info.log" + dmesg | grep -i eth0 >> "${LOGDIR}/network_info.log" + dmesg >> "${LOGDIR}/network_dmesg.log" +} + +check_retroachievements_api() { + # we're not actually checking if the API lets us login as we don't know the users API key but + # we'll request some info from the API and see if it replies with a code we expect + # it should respond as unauthorised/unauthed (401 or 419...) + # we can't use a POST on the login as they use CSRF + local username="dummy" + local api_key="dummy" + local api_url="https://retroachievements.org/API/API_GetAchievementOfTheWeek.php?z=$username&y=$api_key" + + section_header "RetroAchievements API Check" + log_message "Checking RetroAchievements API availability" + + local status=$(curl -s -o /dev/null -w "%{http_code}" --insecure "$api_url") + + case "$status" in + 200) # won't ever happen, we're not passing creds - leaving until i figure out a way to do this + log_message "API is accessible and credentials are valid. Status code: $status \n" + return 0 + ;; + 401) # the one we should get, indicates the API is up and responding to a failed attempt + log_message "API check was successful, returned 401 unauthorized. Status code: $status \n" + return 0 + ;; + 419) # i doubt we'll get this but catch it anyway (appears on a request to: http://retroachievements.org/API/dorequest.php?r=login) + log_message "API check was successful, returned 419 unauthed. Status code: $status \n" + return 0 + ;; + 503) # bad + log_message "API service is unavailable (503). Check back later. \n" + return 1 + ;; + 500) # bad + log_message "Internal server error (500). \n" + return 1 + ;; + 404) # bad + log_message "API endpoint not found (404). \n" + return 1 + ;; + 408) # bad + log_message "Request timed out (408). \n" + return 1 + ;; + 0) # bad + log_message "Failed to connect to API. \n" + return 1 + ;; + *) # bad + log_message "API check failed with status code: $status \n" + return 1 + ;; + esac +} + +check_valid_adaptor() { + local active_interfaces=$(ifconfig | awk '/^[a-zA-Z0-9]/ {print $1}' | grep -v 'lo' | tr -d ':') + + if [ -z "$active_interfaces" ]; then + log_message "No active network interfaces found." + return 1 + else + log_message "Active network interfaces found: $active_interfaces" + return 0 + fi +} + +check_network_complete() { + local interface=$(ifconfig | awk '/^[a-zA-Z0-9]/ {print $1}' | grep -v 'lo' | tr -d ':' | head -n 1) + + if [ -z "$interface" ]; then + log_message "No network interface found to check." + return 1 + fi + + local ip_address=$(ifconfig $interface | grep 'inet addr:' | awk '{print $2}' | cut -d':' -f2) + + if [ -z "$ip_address" ]; then + log_message "$interface does not have an IP address assigned." + return 1 + fi + + local subnet_mask=$(ifconfig $interface | grep 'Mask:' | awk '{print $4}' | cut -d':' -f2) + + if [ -z "$subnet_mask" ]; then + log_message "No subnet mask set for $interface." + return 1 + fi + + local gateway=$(route -n | awk '/^0.0.0.0/ {print $2}' | head -n 1) + + if [ -z "$gateway" ]; then + log_message "No default gateway set for $interface." + return 1 + fi + + log_message "Network check complete for $interface: IP $ip_address, Subnet Mask $subnet_mask, Gateway $gateway" + return 0 +} + +display_summary() { + section_header "Summary of Network Checks" + log_message "Ping Test Results: $ping_success successful out of $ping_total attempts." + log_message "Website Availability: $website_success successful out of $website_total checks." + log_message "Download Test Results: $download_success successful out of $download_total attempts." + + # Determine the overall network health based on the ratio of success to total checks + if [ "$ping_success" -eq "$ping_total" ]; then + log_message "Ping replies from all DNS providers - OK" + elif [ "$ping_success" -gt 0 ]; then + log_message "Ping replies from DNS providers - Degraded" + else + log_message "Ping responses from DNS Providers - Failed" + fi + + if [ "$website_success" -eq "$website_total" ]; then + log_message "Website checks - All sites are reachable" + elif [ "$website_success" -gt 0 ]; then + log_message "Website checks - Some sites are unreachable" + else + log_message "Website checks - All sites are unreachable" + fi + + if [ "$download_success" -eq "$download_total" ]; then + log_message "Download tests - All downloads successful" + elif [ "$download_success" -gt 0 ]; then + log_message "Download tests - Some downloads failed" + else + log_message "Download tests - All downloads failed" + fi +} + +if [ "$#" -gt 0 ]; then + if check_valid_adaptor; then + log_message "Proceeding, valid adaptor found" + else + log_message "Exiting, no valid adaptor found" + fi + + case "$1" in + perform_ping) + perform_ping "$2" "$3" + ;; + check_website) + check_website "$2" + ;; + test_download) + test_download "$2" + ;; + test_dns_resolution) + test_dns_resolution + ;; + check_firmware_for_dns_issue) + check_firmware_for_dns_issue + ;; + check_network_complete) + check_network_complete + ;; + pull_common_logs) + pull_common_logs + ;; + check_retroachievements_api) + check_retroachievements_api + ;; + display_summary) + display_summary + ;; + *) + echo "Unsupported function or incorrect usage." + echo "Usage: $0 []" + exit 1 + ;; + esac + exit +fi + +main() { + # initial setup, check wifi, check chip, check driver is inserted + # check we're connected to a network + section_header "Hardware and config checks" + + check_usb_devices + + # check wifi, obviously + wifi_setting=$(/customer/app/jsonval wifi) + if [ "$wifi_setting" -eq 0 ]; then + log_message "WiFi is disabled, exiting script to avoid running network-dependent checks." + exit 0 # drop out, no logfile will be created + else + log_message "WiFi is enabled, proceeding with network checks." + fi + + # check our adaptor is valid and if we're on a completely negotiated network + if check_valid_adaptor; then + check_network_complete # we're connected but do we have the requirements + fi + + # generic pings, lets see who we can hit + section_header "Network Ping Tests" + perform_ping "8.8.8.8" "Google DNS" + perform_ping "1.1.1.1" "Cloudflare DNS" + perform_ping "208.67.222.222" "OpenDNS" + + # website spiders, pings don't give us everything + section_header "Service and Game Site Checks" + check_website "https://github.com" + check_website "https://www.baidu.com" # chinese + check_website "https://www.naver.com" + check_website "https://www.uol.com.br" # brazil + check_website "https://www.timesofindia.indiatimes.com" + check_website "http://lobby.libretro.com/" + check_website "https://www.lexaloffle.com/bbs/cpost_lister3.php?cat=7" + + # download tests from some core services + section_header "Download Tests" + test_download $THEME_TEST_ASSET + test_download $PORTS_TEST_ASSET + test_download $PICO_BBS_ASSET + + # check cheevosapi status + check_retroachievements_api + + # check if the user is running old firmware that does not support DNS + check_firmware_for_dns_issue + + # pull some interface config and dmesg + section_header "System Network Configuration" + log_message "Collecting network configuration information" + pull_common_logs + + # summary gen + display_summary + + sync + + if [ -x "${DIAGSDIR}/util_exporter.sh" ]; then + log_message "Executing exporter utility." + "${DIAGSDIR}/util_exporter.sh" + else + log_message "Exporter utility not found or not executable." + fi + + log_message "Network checks complete." +} + +main diff --git a/static/build/.tmp_update/script/diagnostics/util_snapshot.sh b/static/build/.tmp_update/script/diagnostics/util_snapshot.sh index 2ae7ea45e..f7b17fd66 100644 --- a/static/build/.tmp_update/script/diagnostics/util_snapshot.sh +++ b/static/build/.tmp_update/script/diagnostics/util_snapshot.sh @@ -50,7 +50,7 @@ main() { snapshot() { system_healthcheck wifi_healthcheck - export_ra_cfg + # export_ra_cfg create_dir_logs create_appcfg_list log "Snapshot generated" From 24a36036421d2b18580e33cbb278005d2600cc71 Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:15:34 +0100 Subject: [PATCH 02/11] Don't call test_dns_res.. from cmdline, not needed. --- static/build/.tmp_update/script/diagnostics/util_netcheck.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index 3e8c17769..b012435f1 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -114,7 +114,7 @@ test_download() { } test_dns_resolution() { - local dns_test_host="google.com" + local dns_test_host="google.co.uk" if nslookup "$dns_test_host" > /dev/null 2>&1; then log_message "DNS resolution test for $dns_test_host successful. \n" return 0 @@ -292,9 +292,6 @@ if [ "$#" -gt 0 ]; then test_download) test_download "$2" ;; - test_dns_resolution) - test_dns_resolution - ;; check_firmware_for_dns_issue) check_firmware_for_dns_issue ;; From b52b4092bf47cfc3d0636e5a62c67d0d5a04750f Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:19:42 +0100 Subject: [PATCH 03/11] Tidy & check for valid DNS server --- .../script/diagnostics/util_netcheck.sh | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index b012435f1..aad5e3547 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -219,30 +219,44 @@ check_network_complete() { fi local ip_address=$(ifconfig $interface | grep 'inet addr:' | awk '{print $2}' | cut -d':' -f2) - if [ -z "$ip_address" ]; then log_message "$interface does not have an IP address assigned." return 1 fi local subnet_mask=$(ifconfig $interface | grep 'Mask:' | awk '{print $4}' | cut -d':' -f2) - if [ -z "$subnet_mask" ]; then log_message "No subnet mask set for $interface." return 1 fi local gateway=$(route -n | awk '/^0.0.0.0/ {print $2}' | head -n 1) - if [ -z "$gateway" ]; then log_message "No default gateway set for $interface." return 1 fi - log_message "Network check complete for $interface: IP $ip_address, Subnet Mask $subnet_mask, Gateway $gateway" + local dns_resolvers=$(grep 'nameserver' /etc/resolv.conf | awk '{print $2}') + if [ -z "$dns_resolvers" ]; then + log_message "No DNS resolvers configured." + return 1 + else + log_message "DNS Resolvers found: $dns_resolvers" + echo $dns_resolvers | tr ' ' '\n' | while read dns_resolver; do + if ping -c 1 -W 2 $dns_resolver > /dev/null 2>&1; then + log_message "Ping to DNS resolver $dns_resolver successful." + else + log_message "Ping to DNS resolver $dns_resolver failed." + return 1 + fi + done + fi + + log_message "Network check complete for $interface: IP $ip_address, Subnet Mask $subnet_mask, Gateway $gateway, DNS Resolvers: $dns_resolvers" return 0 } + display_summary() { section_header "Summary of Network Checks" log_message "Ping Test Results: $ping_success successful out of $ping_total attempts." From 22e00f71e345bb6b80543a573358cf416fd86438 Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:21:12 +0100 Subject: [PATCH 04/11] Remove unnecessary arg handling --- .../build/.tmp_update/script/diagnostics/util_netcheck.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index aad5e3547..6c45ee3b4 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -312,15 +312,9 @@ if [ "$#" -gt 0 ]; then check_network_complete) check_network_complete ;; - pull_common_logs) - pull_common_logs - ;; check_retroachievements_api) check_retroachievements_api ;; - display_summary) - display_summary - ;; *) echo "Unsupported function or incorrect usage." echo "Usage: $0 []" From 2c6826dff7cdb32e0a81db313bc40205c0c61c9c Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:29:16 +0100 Subject: [PATCH 05/11] Remove logfile before starting new logfile --- .../.tmp_update/script/diagnostics/util_netcheck.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index 6c45ee3b4..669914824 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -18,6 +18,7 @@ PORTS_TEST_ASSET="https://github.com/OnionUI/Ports-Collection/releases/latest/do PICO_BBS_ASSET="https://www.lexaloffle.com/bbs/cpost_lister3.php?cat=7" RA_CFG="/mnt/SDCARD/RetroArch/.retroarch/retroarch.cfg" RA_URL="https://retroachievements.org" +LOG_EX_FILE="network_check" ################## ## LOGGING FUNCTION ## @@ -29,7 +30,7 @@ program=$(basename "$0" .sh) log_message() { local message="$(date +"%Y-%m-%d %H:%M:%S") - $1" - echo -e "$message" >> "${LOGDIR}/network_check.log" + echo -e "$message" >> "${LOGDIR}/$LOG_EX_NAME.log" echo -e "$message" # for console } @@ -38,6 +39,12 @@ section_header() { log_message "======== $header ========" } +if [ -f "$LOGDIR/$LOG_EX_FILE.log" ]; then + rm "$LOGDIR/$LOG_EX_FILE.log" +else + echo "$LOGDIR/$LOG_EX_FILE.log Doesn't exist" +fi + ################## ## CHECKING ## ################## From 6acf370da5a45ada87798164def12e4032fedace Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:31:07 +0100 Subject: [PATCH 06/11] Fix log exporter --- static/build/.tmp_update/script/diagnostics/util_netcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index 669914824..52b9866ed 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -30,7 +30,7 @@ program=$(basename "$0" .sh) log_message() { local message="$(date +"%Y-%m-%d %H:%M:%S") - $1" - echo -e "$message" >> "${LOGDIR}/$LOG_EX_NAME.log" + echo -e "$message" >> "${LOGDIR}/$LOG_EX_FILE.log" echo -e "$message" # for console } From 9cc3be588940936fec3221e4bed81ff196ab449e Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:35:37 +0100 Subject: [PATCH 07/11] Update section headers etc --- .../script/diagnostics/util_netcheck.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index 52b9866ed..21177b96f 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -39,6 +39,11 @@ section_header() { log_message "======== $header ========" } +section_header_big() { + local header=$1 + log_message "================ $header ================" +} + if [ -f "$LOGDIR/$LOG_EX_FILE.log" ]; then rm "$LOGDIR/$LOG_EX_FILE.log" else @@ -74,7 +79,6 @@ check_usb_devices() { perform_ping() { local host=$1 local service=$2 - section_header "Ping Test for $service" log_message "Starting ping test for $service: $host" ping_total=$((ping_total + 1)) if ping -c 1 -W 2 $host > /dev/null 2>&1; then @@ -90,7 +94,6 @@ perform_ping() { check_website() { local url=$1 website_total=$((website_total + 1)) - section_header "Website Availability Check" log_message "Checking website availability: $url" if wget -q --no-check-certificate --spider $url; then log_message "Website $url is up.\n" @@ -259,7 +262,7 @@ check_network_complete() { done fi - log_message "Network check complete for $interface: IP $ip_address, Subnet Mask $subnet_mask, Gateway $gateway, DNS Resolvers: $dns_resolvers" + log_message "Network check complete for $interface: IP $ip_address, Subnet Mask $subnet_mask, Gateway $gateway, DNS Resolvers: $dns_resolvers \n" return 0 } @@ -353,13 +356,13 @@ main() { fi # generic pings, lets see who we can hit - section_header "Network Ping Tests" + section_header_big "Network Ping Tests" perform_ping "8.8.8.8" "Google DNS" perform_ping "1.1.1.1" "Cloudflare DNS" perform_ping "208.67.222.222" "OpenDNS" # website spiders, pings don't give us everything - section_header "Service and Game Site Checks" + section_header_big "Service and Game Site Checks" check_website "https://github.com" check_website "https://www.baidu.com" # chinese check_website "https://www.naver.com" @@ -369,7 +372,7 @@ main() { check_website "https://www.lexaloffle.com/bbs/cpost_lister3.php?cat=7" # download tests from some core services - section_header "Download Tests" + section_header_big "Download Tests" test_download $THEME_TEST_ASSET test_download $PORTS_TEST_ASSET test_download $PICO_BBS_ASSET @@ -381,7 +384,7 @@ main() { check_firmware_for_dns_issue # pull some interface config and dmesg - section_header "System Network Configuration" + section_header_big "System Network Configuration" log_message "Collecting network configuration information" pull_common_logs From fc4e57243b2f2fba6c61d0567e8c0d9cd5e5beba Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:37:13 +0100 Subject: [PATCH 08/11] Formatting --- .../build/.tmp_update/script/diagnostics/util_netcheck.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index 21177b96f..93a6034fc 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -135,7 +135,6 @@ test_dns_resolution() { } check_firmware_for_dns_issue() { - section_header "Firmware DNS Check" local version version=$(/etc/fw_printenv miyoo_version) if [ "$version" = "202303021817" ]; then @@ -163,7 +162,6 @@ check_retroachievements_api() { local api_key="dummy" local api_url="https://retroachievements.org/API/API_GetAchievementOfTheWeek.php?z=$username&y=$api_key" - section_header "RetroAchievements API Check" log_message "Checking RetroAchievements API availability" local status=$(curl -s -o /dev/null -w "%{http_code}" --insecure "$api_url") @@ -268,7 +266,6 @@ check_network_complete() { display_summary() { - section_header "Summary of Network Checks" log_message "Ping Test Results: $ping_success successful out of $ping_total attempts." log_message "Website Availability: $website_success successful out of $website_total checks." log_message "Download Test Results: $download_success successful out of $download_total attempts." @@ -337,7 +334,7 @@ fi main() { # initial setup, check wifi, check chip, check driver is inserted # check we're connected to a network - section_header "Hardware and config checks" + section_header_big "Hardware and config checks" check_usb_devices @@ -378,9 +375,11 @@ main() { test_download $PICO_BBS_ASSET # check cheevosapi status + section_header_big "RetroAchievements API Check" check_retroachievements_api # check if the user is running old firmware that does not support DNS + section_header_big "Firmware DNS Check" check_firmware_for_dns_issue # pull some interface config and dmesg @@ -389,6 +388,7 @@ main() { pull_common_logs # summary gen + section_header_big "Summary of Network Checks" display_summary sync From 29c0ff9c5a69a11d97e18c0483f9613ae111e705 Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:40:38 +0100 Subject: [PATCH 09/11] Remove old files if they exist --- static/build/.tmp_update/script/diagnostics/util_netcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index 93a6034fc..f4d4b4186 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -41,11 +41,11 @@ section_header() { section_header_big() { local header=$1 - log_message "================ $header ================" + log_message "================================ $header ================================" } if [ -f "$LOGDIR/$LOG_EX_FILE.log" ]; then - rm "$LOGDIR/$LOG_EX_FILE.log" + rm "$LOGDIR/$LOG_EX_FILE.log" "$LOGDIR/network_info.log" "$LOGDIR/network_dmesg.log" else echo "$LOGDIR/$LOG_EX_FILE.log Doesn't exist" fi From 3b612720295c297d885852b1d2419ce4f25add15 Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:44:13 +0100 Subject: [PATCH 10/11] Update --- static/build/.tmp_update/script/diagnostics/util_netcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index f4d4b4186..ef04a8737 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -40,8 +40,8 @@ section_header() { } section_header_big() { - local header=$1 - log_message "================================ $header ================================" + local header_big=$1 + log_message "================================ $header_big ================================" } if [ -f "$LOGDIR/$LOG_EX_FILE.log" ]; then From 403df87fa3e33d7839f49c2d5f608fd659869a0e Mon Sep 17 00:00:00 2001 From: XK <47260768+XK9274@users.noreply.github.com> Date: Mon, 13 May 2024 21:57:15 +0100 Subject: [PATCH 11/11] Various: - Only delete logfiles if entering through tweaks - Check if driver inserted --- .../script/diagnostics/util_netcheck.sh | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh index ef04a8737..ef346cbee 100644 --- a/static/build/.tmp_update/script/diagnostics/util_netcheck.sh +++ b/static/build/.tmp_update/script/diagnostics/util_netcheck.sh @@ -44,12 +44,6 @@ section_header_big() { log_message "================================ $header_big ================================" } -if [ -f "$LOGDIR/$LOG_EX_FILE.log" ]; then - rm "$LOGDIR/$LOG_EX_FILE.log" "$LOGDIR/network_info.log" "$LOGDIR/network_dmesg.log" -else - echo "$LOGDIR/$LOG_EX_FILE.log Doesn't exist" -fi - ################## ## CHECKING ## ################## @@ -206,6 +200,17 @@ check_retroachievements_api() { esac } +check_driver_inserted() { + local module=$(lsmod | grep '8188fu') + if echo "$module" | grep -q 'Live'; then + log_message "8188fu driver is loaded and active." + return 0 + else + log_message "8188fu driver is missing or not active. Possible WiFi chip failure - does WiFi work?" + return 1 + fi +} + check_valid_adaptor() { local active_interfaces=$(ifconfig | awk '/^[a-zA-Z0-9]/ {print $1}' | grep -v 'lo' | tr -d ':') @@ -332,11 +337,20 @@ if [ "$#" -gt 0 ]; then fi main() { + + # we've entered through tweaks, remove old files + if [ -f "$LOGDIR/$LOG_EX_FILE.log" ]; then + rm "$LOGDIR/$LOG_EX_FILE.log" "$LOGDIR/network_info.log" "$LOGDIR/network_dmesg.log" + else + echo "$LOGDIR/$LOG_EX_FILE.log Doesn't exist" + fi + # initial setup, check wifi, check chip, check driver is inserted # check we're connected to a network section_header_big "Hardware and config checks" check_usb_devices + check_driver_inserted # check wifi, obviously wifi_setting=$(/customer/app/jsonval wifi)