From 10e6cc4c224a48bc8e292b52155661cf452f0a36 Mon Sep 17 00:00:00 2001 From: nagumii Date: Thu, 16 Jan 2025 18:51:49 +0200 Subject: [PATCH 1/8] Create system info tool --- .../usr/local/bin/femto-config | 199 ++++++++++-------- .../usr/local/bin/femto-meshtasticd-config.sh | 12 +- .../usr/local/bin/femto-network-config.sh | 47 ++--- .../local/bin/femto-wifi-config.sh.deprecated | 77 ------- 4 files changed, 141 insertions(+), 194 deletions(-) delete mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-wifi-config.sh.deprecated diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index 3c41aab..8028df3 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -37,18 +37,18 @@ wifi_config() { local wifi_ssid="" local wifi_psk="" local wifi_country="" - wifi_ssid=$(dialog --title "$title2" --inputbox "Enter Wi-Fi SSID:" 8 40 "$(grep -oP '^ *ssid="\K[^"]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current SSID - wifi_psk=$(dialog --title "$title2" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3) - wifi_country=$(dialog --title "$title2" --inputbox "Enter Country Code (US, DE...):" 8 40 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current country + wifi_ssid=$(dialog --no-collapse --title "$title2" --inputbox "Enter Wi-Fi SSID:" 8 40 "$(grep -oP '^ *ssid="\K[^"]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current SSID + wifi_psk=$(dialog --no-collapse --title "$title2" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3) + wifi_country=$(dialog --no-collapse --title "$title2" --inputbox "Enter Country Code (US, DE...):" 8 40 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current country cmd="femto-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\"" [ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\"" cmd="$cmd -r" if [ -z "$wifi_ssid" ]; then - dialog --title "$title2" --msgbox "\nSSID is required to configure Wi-Fi." 8 40 + dialog --no-collapse --title "$title2" --msgbox "\nSSID is required to configure Wi-Fi." 8 40 return fi eval $cmd - dialog --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: (hidden)\nCountry: $wifi_country\nMeshtastic Wi-Fi setting set to ON" 9 40 + dialog --no-collapse --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: (hidden)\nCountry: $wifi_country\nMeshtastic Wi-Fi setting set to ON" 9 40 if [ "$1" = "-w" ]; then exit 0 fi @@ -61,7 +61,7 @@ networking_settings() { wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf" while true; do local option="" - option=$(dialog --cancel-label "Back" --menu "$title" 16 40 4 \ + option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 16 40 4 \ 1 "Turn Wi-Fi on/off" \ 2 "View Wi-Fi settings" \ 3 "Change Wi-Fi settings" \ @@ -80,10 +80,10 @@ networking_settings() { case $option in 1) # Turn Wi-Fi on/off) if ! ip link show wlan0 &>/dev/null; then - dialog --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a wifi adapter connected?" 8 40 + dialog --no-collapse --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a wifi adapter connected?" 8 40 else while true; do - choice=$(dialog --cancel-label "Back" --title "Enable/disable Wi-Fi" --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 11 50 5 \ + choice=$(dialog --no-collapse --cancel-label "Back" --title "Enable/disable Wi-Fi" --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 11 50 5 \ 1 "Turn Wi-Fi on" \ 2 "Turn Wi-Fi off" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -99,31 +99,31 @@ networking_settings() { ;; 2) # View Wi-Fi settings) echo "Getting Wi-Fi configuration..." - dialog --title "$title2" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -w)")" 0 0 + dialog --no-collapse --title "$title2" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -w)")" 0 0 ;; 3) # Change Wi-Fi settings) wifi_config ;; 4) # View ethernet settings) echo "Getting ethernet configuration..." - dialog --title "Ethernet (eth0) settings" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -e)")" 0 0 + dialog --no-collapse --title "Ethernet (eth0) settings" --colors --msgbox "$(echo -e "$(replace_colors "$(femto-network-config.sh -e)")")" 0 0 ;; 5) # Restart networking) - dialog --title "$title2" --yesno "Wi-Fi and Ethernet will be restarted.\nMeshtastic Wi-Fi setting will be set to ON.\n\nProceed?" 10 40 + dialog --no-collapse --title "$title2" --yesno "Wi-Fi and Ethernet will be restarted.\nMeshtastic Wi-Fi setting will be set to ON.\n\nProceed?" 10 40 if [ $? -eq 0 ]; then #unless cancel/no femto-network-config.sh -r fi ;; 6) # set hostname) - new_hostname=$(dialog --title "$title" --inputbox "Enter new hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3) + new_hostname=$(dialog --no-collapse --title "$title" --inputbox "Enter new hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then #unless cancel/no femto-network-config.sh -n "$new_hostname" - dialog --title "$title" --msgbox "Femtofox is now reachable at\n$new_hostname.local" 8 40 + dialog --no-collapse --title "$title" --msgbox "Femtofox is now reachable at\n$new_hostname.local" 8 40 fi ;; 7) # Test internet connection) - dialog --infobox "Testing internet connection..." 5 45 - dialog --title "Internet connectivity test" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -t)")" 8 40 + dialog --no-collapse --infobox "Testing internet connection..." 5 45 + dialog --no-collapse --title "Internet connectivity test" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -t)")" 8 40 ;; 8) return @@ -136,7 +136,7 @@ networking_settings() { femto_pinouts() { while true; do local option="" - option=$(dialog --cancel-label "Back" --menu "Pinouts" 15 40 5 \ + option=$(dialog --no-collapse --cancel-label "Back" --menu "Pinouts" 15 40 5 \ 1 "Femtofox Pro/CE" \ 2 "Femtofox Zero" \ 3 "Femtofox Tiny" \ @@ -151,10 +151,10 @@ femto_pinouts() { fi case $option in - 1) dialog --title "Femtofox" --msgbox "$(femto-pinout.sh -f)" 43 68 ;; - 2) dialog --title "Femtofox Zero" --msgbox "$(femto-pinout.sh -z)" 34 48 ;; - 3) dialog --title "Femtofox Tiny" --msgbox "$(femto-pinout.sh -t)" 38 70 ;; - 4) dialog --title "Luckfox Pico Mini" --msgbox "$(femto-pinout.sh -l)" 23 65 ;; + 1) dialog --no-collapse --title "Femtofox" --msgbox "$(femto-pinout.sh -f)" 43 68 ;; + 2) dialog --no-collapse --title "Femtofox Zero" --msgbox "$(femto-pinout.sh -z)" 34 48 ;; + 3) dialog --no-collapse --title "Femtofox Tiny" --msgbox "$(femto-pinout.sh -t)" 38 70 ;; + 4) dialog --no-collapse --title "Luckfox Pico Mini" --msgbox "$(femto-pinout.sh -l)" 23 65 ;; 5) return ;; esac done @@ -187,7 +187,7 @@ logging() { check_logging elif [ -z "$1" ]; then while true; do - choice=$(dialog --colors --title "Logging" --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(check_logging)")" 12 50 2 \ + choice=$(dialog --no-collapse --colors --title "Logging" --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(check_logging)")" 12 50 2 \ 1 "Enable (default)" \ 2 "Disable" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -215,24 +215,41 @@ system_info() { local swap="$(free -m | awk 'NR==3{printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}')" local mounted_drives="$([ "$(for dir in /mnt/*/; do echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "Mounted drives: $(for dir in /mnt/*; do echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')")" local os_version="Foxbuntu v$(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release)$(output=$(grep -o 'patch=[1-9][0-9]*' /etc/foxbuntu-release | cut -d= -f2) && [ -n "$output" ] && echo ".$output")$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release) ($(lsb_release -d | awk -F'\t' '{print $2}') $(lsb_release -c | awk -F'\t' '{print $2}'))" - info="\ -Femtofox\n\ + local info="\ + Femtofox\n\ Core: Luckfox Pico Mini\n\ - CPU:\n\ +Operating System: $os_version\n\ +Kernel Version: $(uname -r)\n\ +Uptime: $(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')\n\ +Logging: $(logging "check" | sed 's/\x1b\[[0-9;]*m//g')\n\ +System time: $(date)\n\ +\n\ + CPU:\n\ Architecture: $cpu_architecture\n\ Model: $cpu_model\n\ Serial # $cpu_serial\n\ Cores: 1\n\ Speed: $cpu_speed\n\ - Storage:\n\ +\n\ + Storage:\n\ microSD size: $microsd_size\n\ Memory: $memory\n\ Swap: $swap\n\ $mounted_drives\n\ \n\ -Uptime:$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')\n\ -Operating System: $os_version\n\ -$(replace_colors "$(femto-network-config.sh -e)")\ + Networking (wlan0 & eth0 only):\n\ +$(replace_colors "$(femto-network-config.sh -w | grep -v '^$' | grep -v '^MAC Address')")\n\ +--- +$(replace_colors "$(femto-network-config.sh -e)")\n\ +\n\ + Attached devices:\n\ +LoRa radio: $(replace_colors "$(femto-meshtasticd-config.sh -k)")\n\ +$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB: None detected"}')\n\ +i2c devices: $(i2cdetect -y 3 | awk 'NR>1 {for(i=2;i<=17;i++) if ($i == "ff" || $i == "UU") { printf "0x%02x ", (i-2) + (NR-2)*16} }' | tr -d '\n' )\n\ +\n\ + Kernel: +Modules active: $(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)\n\ +Boot modules: $(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")\ " echo -e "$info" } @@ -242,18 +259,19 @@ utilities() { local title="Utilities" while true; do local option="" - option=$(dialog --cancel-label "Back" --menu "$title" 18 40 4 \ - 1 "Set system time" \ - 2 "Kernel modules" \ - 3 "Re-run first-boot script" \ - 4 "Run USB configuration tool" \ - 5 "Run OEM luckfox-config" \ - 6 "Process viewer/manager" \ - 7 "Disable/enable logging" \ - 8 "Reboot" \ - 9 "Shutdown" \ + option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 19 40 4 \ + 1 "System info" \ + 2 "Set system time" \ + 3 "Kernel modules" \ + 4 "Re-run first-boot script" \ + 5 "Run USB configuration tool" \ + 6 "Run OEM luckfox-config" \ + 7 "Process viewer/manager" \ + 8 "Disable/enable logging" \ + 9 "Reboot" \ + 10 "Shutdown" \ "" "" \ - 10 "Back to Main Menu" 3>&1 1>&2 2>&3) + 11 "Back to Main Menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -261,38 +279,42 @@ utilities() { fi case $option in - 1) femto-set-time.sh ;; # set timezone) - 2) # Kernel modules) - dialog --title "$title" --msgbox "Kernel modules are loadable pieces of code that extend a Linux kernel's functionality without requiring a reboot. Common examples include device drivers, file systems, or system calls.\n\nThis tool will allow you to add pre-compiled modules to the Foxbuntu kernel.\n\nModules currently autostarting at boot: $(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")\n\nCurrently active modules: $(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ')" 18 65 + 1) + dialog --no-collapse --infobox "Loading system info..." 5 45 + dialog --no-collapse --colors --title "System info" --msgbox "$(system_info)" 0 0 + ;; + 2) femto-set-time.sh ;; # set timezone) + 3) # Kernel modules) + dialog --no-collapse --title "$title" --msgbox "Kernel modules are loadable pieces of code that extend a Linux kernel's functionality without requiring a reboot. Common examples include device drivers, file systems, or system calls.\n\nThis tool will allow you to add pre-compiled modules to the Foxbuntu kernel.\n\nModules currently autostarting at boot: $(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")\n\nCurrently active modules: $(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ')" 18 65 femto-kernel-modules.sh ;; - 3) femto-runonce.sh ;; # Re-run first-boot script) - 4) # USB config) - dialog --title "$title" --yesno "The USB configuration tool allows you to set critical Femtofox settings with a text file on a USB flash drive.\n\nFor more information, visit\ngithub.com/noon92/femtofox/blob/main/usb_config.md\n\nThis tool is run automatically at boot.\n\nRun now?" 14 60 + 4) femto-runonce.sh ;; # Re-run first-boot script) + 5) # USB config) + dialog --no-collapse --title "$title" --yesno "The USB configuration tool allows you to set critical Femtofox settings with a text file on a USB flash drive.\n\nFor more information, visit\ngithub.com/noon92/femtofox/blob/main/usb_config.md\n\nThis tool is run automatically at boot.\n\nRun now?" 14 60 if [ $? -eq 0 ]; then #unless cancel/no femto-usb-config-tool.sh pause fi ;; - 5) luckfox-config ;; - 6) htop ;; - 7) logging ;; - 8) # reboot) - dialog --title "$title" --yesno "Reboot now?\n\nTip: Reboot can also be triggered by long-pressing the BOOT button on the luckfox." 10 45 + 6) luckfox-config ;; + 7) htop ;; + 8) logging ;; + 9) # reboot) + dialog --no-collapse --title "$title" --yesno "Reboot now?\n\nTip: Reboot can also be triggered by long-pressing the BOOT button on the luckfox." 10 45 if [ $? -eq 0 ]; then #unless cancel/no - dialog --infobox "Rebooting..." 5 45 + dialog --no-collapse --infobox "Rebooting..." 5 45 reboot fi ;; - 9) # shutdown) - dialog --title "$title" --yesno "Shut down now?\n\nTo power system back on, disconnect/reconnect power.\n\nThe system shutdown command prevents damage to the filesystem from power interrupts, but does not stop power consumption.\n\nTip: You can also shut down the Femtofox by pressing the BOOT button for 5 seconds or by running \`sudo halt\`." 14 60 + 10) # shutdown) + dialog --no-collapse --title "$title" --yesno "Shut down now?\n\nTo power system back on, disconnect/reconnect power.\n\nThe system shutdown command prevents damage to the filesystem from power interrupts, but does not stop power consumption.\n\nTip: You can also shut down the Femtofox by pressing the BOOT button for 5 seconds or by running \`sudo halt\`." 14 60 if [ $? -eq 0 ]; then #unless cancel/no - dialog --infobox "Shutting down...\n\nPower consumption will not stop." 5 45 + dialog --no-collapse --infobox "Shutting down...\n\nPower consumption will not stop." 5 45 logger "User requested system halt" halt fi ;; - 10) return ;; + 11) return ;; esac done } @@ -303,7 +325,7 @@ set_lora_radio() { echo "Checking LoRa radio..." local option="" #Display filename, if exists: $(files=$(ls /etc/meshtasticd/config.d/* 2>/dev/null) && [ -n "$files" ] && echo "\n\nConfiguration files in use:\n$files" | paste -sd, -)) - option=$(dialog --colors --cancel-label "Back" --title "Meshtastic LoRa radio" --menu "Currently configured LoRa radio:\n$(replace_colors "$(femto-meshtasticd-config.sh -k)")$(ls -1 /etc/meshtasticd/config.d 2>/dev/null | paste -sd ', ' - | sed 's/^/ (/; s/$/)/; s/,/, /g' | grep -v '^ ()$')" 18 50 10 \ + option=$(dialog --no-collapse --colors --cancel-label "Back" --title "Meshtastic LoRa radio" --menu "Currently configured LoRa radio:\n$(replace_colors "$(femto-meshtasticd-config.sh -k)")$(ls -1 /etc/meshtasticd/config.d 2>/dev/null | paste -sd ', ' - | sed 's/^/ (/; s/$/)/; s/,/, /g' | grep -v '^ ()$')" 18 50 10 \ "Ebyte e22-900m30s" "(SX1262_TCXO)" \ "Ebyte e22-900m22s" "(SX1262_TCXO)"\ "Ebyte e80-900m22s" "(SX1262_XTAL)"\ @@ -362,15 +384,8 @@ meshtasticd_settings() { local title="Meshtastic Settings" while true; do echo "Checking Meshtasticd service state..." - if echo "$(systemctl status meshtasticd)" | grep -q "active (running)"; then - local service_state="\Z4\Zuonline\Zn" - elif echo "$(systemctl status meshtasticd)" | grep -q "inactive (dead)"; then - local service_state="\Z1\Zuoffline\Zn" - else - local service_state="unknown" - fi local option="" - option=$(dialog --colors --title "$title" --cancel-label "Back" --menu "Meshtasticd service is $service_state$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 22 50 4 \ + option=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 22 50 4 \ 1 "View configuration URL & QR code" \ 2 "Set new configuration URL" \ 3 "Set LoRa radio" \ @@ -394,14 +409,14 @@ meshtasticd_settings() { case $option in 1) #Get current configuration URL & QR code) - dialog --infobox "Getting Meshtastic QR code and URL..." 5 45 + dialog --no-collapse --infobox "Getting Meshtastic QR code and URL..." 5 45 femto-meshtasticd-config.sh -g pause ;; 2) - newurl=$(dialog --title "Meshtastic URL" --inputbox "New Meshtasticd URL (SHIFT+INS to paste):" 8 60 3>&1 1>&2 2>&3) + newurl=$(dialog --no-collapse --title "Meshtastic URL" --inputbox "New Meshtasticd URL (SHIFT+INS to paste):" 8 60 3>&1 1>&2 2>&3) if [ -n "$newurl" ]; then #if a URL was entered - dialog --title "$title" --yesno "New Meshtasticd URL:\n$newurl\n\nConfirm?" 15 60 + dialog --no-collapse --title "$title" --yesno "New Meshtasticd URL:\n$newurl\n\nConfirm?" 15 60 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -q "$newurl" pause @@ -412,25 +427,25 @@ meshtasticd_settings() { set_lora_radio ;; 4) - dialog --infobox "Getting admin keys..." 5 45 - dialog --title "Admin keys" --msgbox "Up to 3 admin keys are permitted, more will be ignored.\n\nKeys:$(femto-meshtasticd-config.sh -v | tail -n 1 | sed 's/|n/\\n/g')" 0 0 + dialog --no-collapse --infobox "Getting admin keys..." 5 45 + dialog --no-collapse --title "Admin keys" --msgbox "Up to 3 admin keys are permitted, more will be ignored.\n\nKeys:$(femto-meshtasticd-config.sh -v | tail -n 1 | sed 's/|n/\\n/g')" 0 0 ;; 5) #set admin key) - key=$(dialog --title "Meshtastic Admin Key" --inputbox "Meshtastic admin key - up to 3, more will be ignored.\n\n(SHIFT+INS to paste):" 11 40 3>&1 1>&2 2>&3) + key=$(dialog --no-collapse --title "Meshtastic Admin Key" --inputbox "Meshtastic admin key - up to 3, more will be ignored.\n\n(SHIFT+INS to paste):" 11 40 3>&1 1>&2 2>&3) if [ -n "$key" ]; then #if a URL was entered femto-meshtasticd-config.sh -a "$key" pause fi ;; 6) - dialog --title "$title" --yesno "Meshtasticd can have up to 3 admin keys.\nClear admin key list?" 0 0 + dialog --no-collapse --title "$title" --yesno "Meshtasticd can have up to 3 admin keys.\nClear admin key list?" 0 0 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -c pause fi ;; 7) #legacy admin) - dialog --infobox "Getting current legacy admin state..." 5 45 + dialog --no-collapse --infobox "Getting current legacy admin state..." 5 45 state=$(sudo femto-meshtasticd-config.sh -p) if echo "$state" | grep -q "True"; then state="Enabled" @@ -440,7 +455,7 @@ meshtasticd_settings() { state="Error" fi while true; do - choice=$(dialog --title "Meshtasticd Legacy Admin" --menu "Current state: $state" 10 40 5 \ + choice=$(dialog --no-collapse --title "Meshtasticd Legacy Admin" --menu "Current state: $state" 10 40 5 \ 1 "Enable" \ 2 "Disable" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -454,42 +469,42 @@ meshtasticd_settings() { done ;; 8) #check meshtasticd service status) - dialog --infobox "Getting Meshtasticd service status..." 5 45 - dialog --title "Meshtasticd service status" --msgbox "$(systemctl status meshtasticd)" 0 0 + dialog --no-collapse --infobox "Getting Meshtasticd service status..." 5 45 + dialog --no-collapse --title "Meshtasticd service status" --msgbox "$(systemctl status meshtasticd)" 0 0 ;; 9) #test mesh connectivity) - dialog --title "Meshtastic connectivity test" --yesno "Will send \"test\" to channel 0 and wait for acknowledgement. Will try up to 3 times.\n\nPerform test?" 10 45 + dialog --no-collapse --title "Meshtastic connectivity test" --yesno "Will send \"test\" to channel 0 and wait for acknowledgement. Will try up to 3 times.\n\nPerform test?" 10 45 if [ $? -eq 0 ]; then #unless cancel/no - dialog --infobox "Performing mesh connectivity test.\n\nThis may take a while..." 6 45 - dialog --title "Meshtasticd service status" --msgbox "$(femto-meshtasticd-config.sh -r)" 0 0 + dialog --no-collapse --infobox "Performing mesh connectivity test.\n\nThis may take a while..." 6 45 + dialog --no-collapse --title "Meshtasticd service status" --msgbox "$(femto-meshtasticd-config.sh -r)" 0 0 fi ;; 10) #start/restart meshtasticd) - dialog --title "$title" --yesno "Start/restart Meshtasticd service?" 5 45 + dialog --no-collapse --title "$title" --yesno "Start/restart Meshtasticd service?" 5 45 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -s - dialog --msgbox "Meshtasticd service started/restarted." 5 45 + dialog --no-collapse --msgbox "Meshtasticd service started/restarted." 5 45 fi ;; 11) #stop meshtasticd) - dialog --title "$title" --yesno "Stop Meshtasticd service?" 5 45 + dialog --no-collapse --title "$title" --yesno "Stop Meshtasticd service?" 5 45 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -t - dialog --msgbox "Meshtasticd service stopped." 5 45 + dialog --no-collapse --msgbox "Meshtasticd service stopped." 5 45 fi ;; 12) #Upgrade meshtasticd) - dialog --title "$title" --yesno "Upgrade Meshtasticd?\nRequires internet connection." 0 0 + dialog --no-collapse --title "$title" --yesno "Upgrade Meshtasticd?\nRequires internet connection." 0 0 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -u pause fi ;; 13) #uninstall meshtasticd) - dialog --title "$title" --yesno "Uninstall Meshtasticd?\n\nFoxbuntu was designed with Meshtasticd integration in mind, and may behave unexpectedly if Meshtasticd is removed." 0 0 + dialog --no-collapse --title "$title" --yesno "Uninstall Meshtasticd?\n\nFoxbuntu was designed with Meshtasticd integration in mind, and may behave unexpectedly if Meshtasticd is removed." 0 0 if [ $? -eq 0 ]; then femto-meshtasticd-config.sh -x - dialog --msgbox "Meshtasticd uninstalled. To purge all remnants, run \`sudo apt purge\`.\nAfter reinstallation but before first launch, run the \"first boot script\" from the misc menu." 8 40 + dialog --no-collapse --msgbox "Meshtasticd uninstalled. To purge all remnants, run \`sudo apt purge\`.\nAfter reinstallation but before first launch, run the \"first boot script\" from the misc menu." 8 40 fi ;; 14) @@ -504,7 +519,7 @@ help_menu() { while true; do local title="Help / About" local option="" - option=$(dialog --cancel-label "Back" --menu "$title" 0 0 7 \ + option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 0 0 7 \ 1 "About Femtofox" \ 2 "Display pinout" \ 3 "Femtofox licensing info - short" \ @@ -522,13 +537,13 @@ help_menu() { case $option in 1) #About Femtofox) - dialog --title "About Femtofox" --backtitle "Foxbuntu $(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'patch=\K[0-9]+' /etc/foxbuntu-release)$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release)" --msgbox "$(femto-license.sh -a)" 18 65 + dialog --no-collapse --title "About Femtofox" --backtitle "Foxbuntu $(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'patch=\K[0-9]+' /etc/foxbuntu-release)$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release)" --msgbox "$(femto-license.sh -a)" 18 65 ;; 2) #Display pinout) femto_pinouts ;; 3) #Femtofox licensing info - short) - dialog --title "Femtofox license" --msgbox "$(femto-license.sh -f)" 28 60 + dialog --no-collapse --title "Femtofox license" --msgbox "$(femto-license.sh -f)" 28 60 ;; 4) #Femtofox licensing info - long) clear @@ -536,13 +551,13 @@ help_menu() { pause ;; 5) #Meshtastic licensing info) - dialog --title "Meshtastic license" --msgbox "$(femto-license.sh -m)" 0 0 + dialog --no-collapse --title "Meshtastic license" --msgbox "$(femto-license.sh -m)" 0 0 ;; 6) #About Luckfox) - dialog --title "About Luckfox" --msgbox "$(femto-license.sh -l)" 0 0 + dialog --no-collapse --title "About Luckfox" --msgbox "$(femto-license.sh -l)" 0 0 ;; 7) #About Ubuntu) - dialog --title "About Ubuntu" --msgbox "$(femto-license.sh -u)" 0 0 + dialog --no-collapse --title "About Ubuntu" --msgbox "$(femto-license.sh -u)" 0 0 ;; 8) return @@ -589,7 +604,7 @@ if [ -n "$1" ]; then fi # Main menu while true; do - choice=$(dialog --title "$(date)" --cancel-label "Exit" --menu "Femtofox Config" 15 40 5 \ + choice=$(dialog --no-collapse --title "$(date)" --cancel-label "Exit" --menu "Femtofox Config" 15 40 5 \ 1 "Settings wizard" \ 2 "Networking" \ 3 "Meshtasticd" \ diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh index 2fe22e5..881219b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh @@ -19,6 +19,7 @@ Options are: -r Test mesh connectivity by sending "test" to channel 0 and waiting for. Will attempt 3 times -s Start/restart Meshtasticd Service -t Stop Meshtasticd Service +-S Get Meshtasticd Service state -u Upgrade Meshtasticd -x Uninstall Meshtasticd -m Meshtastic update tool. Syntax: \`femto-meshtasticd-config.sh -m \"--set security.admin_channel_enabled false\" 10 \"Disable legacy admin\"\` @@ -68,7 +69,7 @@ meshtastic_update() { } # Parse options -while getopts ":hgkl:q:va:cpo:struxm" opt; do +while getopts ":hgkl:q:va:cpo:sStruxm" opt; do case ${opt} in h) # Option -h (help) echo -e "$help" @@ -139,6 +140,15 @@ while getopts ":hgkl:q:va:cpo:struxm" opt; do systemctl restart meshtasticd echo "Meshtasticd service started/restarted." ;; + S) # Option -S (Get Meshtasticd Service state) + if echo "$(systemctl status meshtasticd)" | grep -q "active (running)"; then + echo -e "\033[4m\033[0;34monline\033[0m" + elif echo "$(systemctl status meshtasticd)" | grep -q "inactive (dead)"; then + echo -e "\033[4m\033[0;31moffline\033[0m" + else + echo "unknown" + fi + ;; t) # Option -t (stop Meshtasticd service) systemctl stop meshtasticd echo "Meshtasticd service stopped." diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh index 2340097..aae75e8 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh @@ -77,42 +77,41 @@ while getopts ":hx:Ts:p:c:ewn:tr" opt; do ;; e) # Option -e (ethernet settings) status=$(ip link show eth0 | grep -o 'state [A-Za-z]*' | awk '{print $2}') -echo -e "Ethernet status: $([ "$status" == "UP" ] && echo -e "\033[4m\033[0;34mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")" +echo -e "Ethernet status: $([ "$status" == "UP" ] && echo -e "\033[4m\033[0;34mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")" if [ "$status" == "UP" ]; then - echo "\nIPv4 Address: $(ifconfig eth0 | grep 'inet ' | awk '{print $2}')\n\ -IPv6 Address: $(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')" + echo "IPv4 Address: $(ifconfig eth0 | grep 'inet ' | awk '{print $2}')\n\ +IPv6 Address: $(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')" fi -echo "\nMAC Address: $(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\ -Hostname: $(hostname).local" +echo -e "MAC Address: $(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\ +Hostname: $(hostname).local" ;; w) # Option -w (wifi settings) - if [ "$(ip link show wlan0)" ]; then # if wlan0 exists + wifi_settings="SSID: $(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)\n\ +Password: (hidden)\n\ +Country: $(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)" + + if ip link show wlan0 2>/dev/null | grep -q "wlan0"; then mac_address_line="MAC address: $(ifconfig wlan0 | grep ether | awk '{print $2}')\n" if [ "$(cat /etc/wifi_state.txt)" = "up" ]; then - wifi_status="\033[4m\033[0;34menabled\033[0m" + echo -e "Wi-Fi status: \033[4m\033[0;34menabled\033[0m\n\ +Connected to: $(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}' | sed 's/^$/none/')\n\ +Signal Strength: $(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\ +Current IP: $(hostname -I | awk '{print $1}')\n +Hostname: $(hostname).local\n\ +$mac_address_line" else if ip link show wlan0 &>/dev/null; then # if wlan0 exists - wifi_status="\033[0;31mdisabled\033[0m" + echo -e "Wi-Fi status: \033[0;31mdisabled\033[0m\n\ +\n\ +$wifi_settings" fi fi else - wifi_status="\033[0;31mwlan0 not detected\033[0m" - fi - echo -e "\ -$(echo -e "\ -SSID: $(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)\n\ -Password: (hidden)\n\ -Country: $(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)\n\ -WiFi status: $wifi_status\ + echo -e "Wi-Fi status: \033[0;31mwlan0 not detected\033[0m\n\ \n\ -$(if [[ "$wifi_status" == *"enabled"* ]]; then - echo -e "\nConnected to: $(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}' | sed 's/^$/none/')\n\ -Signal Strength: $(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\ -Current IP: $(hostname -I | awk '{print $1}')\n" -fi)")\n\ -Hostname: $(hostname).local\n\ -$mac_address_line -For more details, enter \`iwconfig\`." +Wi-Fi settings:\n\ +$wifi_settings" + fi ;; t) # Option -t (test internet connection) # Define ping targets and initialize counter diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-wifi-config.sh.deprecated b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-wifi-config.sh.deprecated deleted file mode 100644 index 6d9afec..0000000 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-wifi-config.sh.deprecated +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root. Try \`sudo femto-wifi-config\`." - exit 1 -fi - -wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf" -help=$(cat < Date: Thu, 16 Jan 2025 23:49:56 +0200 Subject: [PATCH 2/8] continued work on sysinfo --- .../usr/local/bin/femto-config | 13 +++++++---- .../usr/local/bin/femto-meshtasticd-config.sh | 22 ++++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index 8028df3..e3b8c1d 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -205,7 +205,6 @@ logging() { } system_info() { - local cpu_architecture="armv7l (armhf 32bit)" local cpu_model="Rockchip rv1103 (rev$(awk '/CPU revision/ {print $4}' /proc/cpuinfo))" local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)" @@ -215,6 +214,8 @@ system_info() { local swap="$(free -m | awk 'NR==3{printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}')" local mounted_drives="$([ "$(for dir in /mnt/*/; do echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "Mounted drives: $(for dir in /mnt/*; do echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')")" local os_version="Foxbuntu v$(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release)$(output=$(grep -o 'patch=[1-9][0-9]*' /etc/foxbuntu-release | cut -d= -f2) && [ -n "$output" ] && echo ".$output")$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release) ($(lsb_release -d | awk -F'\t' '{print $2}') $(lsb_release -c | awk -F'\t' '{print $2}'))" + local boot_modules="$(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")" + local i2c_addresses="$(i2cdetect -y 3 | awk 'NR>1 {for(i=2;i<=17;i++) if ($i == "ff" || $i == "UU") { printf "0x%02x ", (i-2) + (NR-2)*16} }' | tr -d '\n' )" local info="\ Femtofox\n\ Core: Luckfox Pico Mini\n\ @@ -237,7 +238,7 @@ Memory: $memory\n\ Swap: $swap\n\ $mounted_drives\n\ \n\ - Networking (wlan0 & eth0 only):\n\ + Networking (wlan0 & eth0):\n\ $(replace_colors "$(femto-network-config.sh -w | grep -v '^$' | grep -v '^MAC Address')")\n\ --- $(replace_colors "$(femto-network-config.sh -e)")\n\ @@ -245,11 +246,15 @@ $(replace_colors "$(femto-network-config.sh -e)")\n\ Attached devices:\n\ LoRa radio: $(replace_colors "$(femto-meshtasticd-config.sh -k)")\n\ $(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB: None detected"}')\n\ -i2c devices: $(i2cdetect -y 3 | awk 'NR>1 {for(i=2;i<=17;i++) if ($i == "ff" || $i == "UU") { printf "0x%02x ", (i-2) + (NR-2)*16} }' | tr -d '\n' )\n\ +i2c devices: $i2c_addresses\n\ \n\ Kernel: Modules active: $(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)\n\ -Boot modules: $(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")\ +Boot modules: $boot_modules\n\ +\n\ + Meshtasticd:\n\ +Service status: $(femto-meshtasticd-config.sh -S)\n\ +$(femto-meshtasticd-config.sh -i)\ " echo -e "$info" } diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh index 881219b..5a20d76 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh @@ -7,6 +7,7 @@ fi help=$(cat < 0" | bc) -eq 1 ]] && echo -e "Override freq: $overrideFrequency")\n\ +Uptime: $(echo "$output" | grep -oP '"uptimeSeconds":\s*\K\d+' | head -n 1 | awk '{days=int($1/86400); hrs=int(($1%86400)/3600); mins=int(($1%3600)/60); secs=int($1%60); printf "%d days %02d:%02d:%02d\n", days, hrs, mins, secs}')\n\ +Public key: $(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)\ +" + ;; g) # Option -g (get config URL) url=$(meshtastic --host --qr-all | grep -oP '(?<=Complete URL \(includes all channels\): )https://[^ ]+') #add look for errors clear @@ -142,9 +158,9 @@ while getopts ":hgkl:q:va:cpo:sStruxm" opt; do ;; S) # Option -S (Get Meshtasticd Service state) if echo "$(systemctl status meshtasticd)" | grep -q "active (running)"; then - echo -e "\033[4m\033[0;34monline\033[0m" + echo -e "\033[4m\033[0;34mrunning\033[0m" elif echo "$(systemctl status meshtasticd)" | grep -q "inactive (dead)"; then - echo -e "\033[4m\033[0;31moffline\033[0m" + echo -e "\033[4m\033[0;31mnot running\033[0m" else echo "unknown" fi From 4e61869b4a9ad9c144aa332f18265b71304506db Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 17 Jan 2025 01:33:29 +0200 Subject: [PATCH 3/8] Continued sysinfo --- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-config | 5 +++-- .../usr/local/bin/femto-meshtasticd-config.sh | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index e3b8c1d..6adb3d8 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -249,12 +249,13 @@ $(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i< i2c devices: $i2c_addresses\n\ \n\ Kernel: +Version: $(uname -r) Modules active: $(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)\n\ Boot modules: $boot_modules\n\ \n\ Meshtasticd:\n\ -Service status: $(femto-meshtasticd-config.sh -S)\n\ -$(femto-meshtasticd-config.sh -i)\ +Service status: $(replace_colors "$(femto-meshtasticd-config.sh -S)")\n\ +$(replace_colors "$(femto-meshtasticd-config.sh -i)")\ " echo -e "$info" } diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh index 5a20d76..34c190a 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh @@ -80,7 +80,8 @@ while getopts ":higkl:q:va:cpo:sStruxm" opt; do echo -e "\ Version: $(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)\n\ Node name: $(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)\n\ -NodeID: $(printf "%X\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1) | tr '[:upper:]' '[:lower:]') ($(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))\n\ +NodeID: $(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)) ($(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))\n\ +TX enabled? $(txEnabled=$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+'); [[ "$txEnabled" == "true" ]] && echo "\033[0;34menabled\033[0m" || echo "\033[0;31mdisabled\033[0m")\n\ Role: $(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)\n\ Preset: $(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')\n\ Region: $(echo "$output" | grep -oP '"region":\s*"\K[^"]+')\n\ From bb99382e78cc766f87137397450be7dcf9af4dd6 Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 17 Jan 2025 18:07:26 +0200 Subject: [PATCH 4/8] Complete initial sysinfo release --- .../usr/local/bin/femto-config | 120 +++++++++++------- .../usr/local/bin/femto-meshtasticd-config.sh | 29 +++-- 2 files changed, 94 insertions(+), 55 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index 6adb3d8..6ca5aa8 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -204,6 +204,7 @@ logging() { fi } +# at some point this will be moved to a different script, and have many functions instead of one giant dump system_info() { local cpu_architecture="armv7l (armhf 32bit)" local cpu_model="Rockchip rv1103 (rev$(awk '/CPU revision/ {print $4}' /proc/cpuinfo))" @@ -214,16 +215,35 @@ system_info() { local swap="$(free -m | awk 'NR==3{printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}')" local mounted_drives="$([ "$(for dir in /mnt/*/; do echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "Mounted drives: $(for dir in /mnt/*; do echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')")" local os_version="Foxbuntu v$(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release)$(output=$(grep -o 'patch=[1-9][0-9]*' /etc/foxbuntu-release | cut -d= -f2) && [ -n "$output" ] && echo ".$output")$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release) ($(lsb_release -d | awk -F'\t' '{print $2}') $(lsb_release -c | awk -F'\t' '{print $2}'))" + local system_uptime="$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')" + local logging_enabled="$(logging "check" | sed 's/\x1b\[[0-9;]*m//g')" local boot_modules="$(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")" local i2c_addresses="$(i2cdetect -y 3 | awk 'NR>1 {for(i=2;i<=17;i++) if ($i == "ff" || $i == "UU") { printf "0x%02x ", (i-2) + (NR-2)*16} }' | tr -d '\n' )" - local info="\ + local wifi_status="$(replace_colors "$(femto-network-config.sh -w | grep -v '^$' | grep -v '^Hostname')")" #remove hostname line, as it's identical to the one in ethernet settings + local eth_status="$(replace_colors "$(femto-network-config.sh -e)")" + local usb_devices="$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB: None detected"}')" + local kernel_modules_active="$(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)" + local lora_radio="$(replace_colors "$(femto-meshtasticd-config.sh -k)")" + local meshtasticd_service_status="$(replace_colors "$(femto-meshtasticd-config.sh -S)")" + local meshtasticd_info="$(replace_colors "$(femto-meshtasticd-config.sh -i)")" + local usb_mode="$(cat /sys/devices/platform/ff3e0000.usb2-phy/otg_mode)" + local spi0_state="$([ "$(awk -F= '/^SPI0_M0_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")" + local spi0_speed="$((0x$(xxd -p /sys/firmware/devicetree/base/spi@ff500000/spidev@0/spi-max-frequency | tr -d '\n')))" + local i2c3_state="$([ "$(awk -F= '/^I2C3_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")" + local i2c3_speed="$(awk -F= '/^I2C3_M1_SPEED/ {print $2}' /etc/luckfox.cfg)" + local uart3_state="$([ "$(awk -F= '/^UART3_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")" + local uart4_state="$([ "$(awk -F= '/^UART4_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")" + + echo -e "\ Femtofox\n\ Core: Luckfox Pico Mini\n\ Operating System: $os_version\n\ -Kernel Version: $(uname -r)\n\ -Uptime: $(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')\n\ -Logging: $(logging "check" | sed 's/\x1b\[[0-9;]*m//g')\n\ +Kernel version: $(uname -r)\n\ +Uptime: $system_uptime\n\ +Logging: $logging_enabled\n\ System time: $(date)\n\ +K modules active: $kernel_modules_active\n\ +K boot modules: $boot_modules\n\ \n\ CPU:\n\ Architecture: $cpu_architecture\n\ @@ -239,25 +259,28 @@ Swap: $swap\n\ $mounted_drives\n\ \n\ Networking (wlan0 & eth0):\n\ -$(replace_colors "$(femto-network-config.sh -w | grep -v '^$' | grep -v '^MAC Address')")\n\ +$wifi_status\n\ --- -$(replace_colors "$(femto-network-config.sh -e)")\n\ +$eth_status\n\ +\n\ + Interfaces:\n\ +USB mode: $usb_mode\n\ +SPI-0 state: $spi0_state\n\ +SPI-0 speed: $spi0_speed\n\ +i2c-3 state: $i2c3_state\n\ +i2c-3 speed: $i2c3_speed\n\ +UART-3 state: $uart3_state\n\ +UART-4 state: $uart4_state\n\ \n\ Attached devices:\n\ -LoRa radio: $(replace_colors "$(femto-meshtasticd-config.sh -k)")\n\ -$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB: None detected"}')\n\ +LoRa radio: $lora_radio\n\ +$usb_devices\n\ i2c devices: $i2c_addresses\n\ -\n\ - Kernel: -Version: $(uname -r) -Modules active: $(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)\n\ -Boot modules: $boot_modules\n\ \n\ Meshtasticd:\n\ -Service status: $(replace_colors "$(femto-meshtasticd-config.sh -S)")\n\ -$(replace_colors "$(femto-meshtasticd-config.sh -i)")\ +Service status: $meshtasticd_service_status\n\ +$meshtasticd_info\ " -echo -e "$info" } # utilities @@ -391,22 +414,23 @@ meshtasticd_settings() { while true; do echo "Checking Meshtasticd service state..." local option="" - option=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 22 50 4 \ - 1 "View configuration URL & QR code" \ - 2 "Set new configuration URL" \ - 3 "Set LoRa radio" \ - 4 "View admin keys" \ - 5 "Set admin key" \ - 6 "Clear admin keys" \ - 7 "Legacy admin channel" \ - 8 "Detailed Meshtasticd service status" \ - 9 "Mesh connectivity test" \ - 10 "Start/restart Meshtasticd service" \ - 11 "Stop Meshtasticd service" \ - 12 "Upgrade/install Meshtasticd" \ - 13 "Uninstall Meshtasticd" \ + option=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 23 50 4 \ + 1 "View node info" \ + 2 "View configuration URL & QR code" \ + 3 "Set new configuration URL" \ + 4 "Set LoRa radio" \ + 5 "View admin keys" \ + 6 "Set admin key" \ + 7 "Clear admin keys" \ + 8 "Legacy admin channel" \ + 9 "Detailed Meshtasticd service status" \ + 10 "Mesh connectivity test" \ + 11 "Start/restart Meshtasticd service" \ + 12 "Stop Meshtasticd service" \ + 13 "Upgrade/install Meshtasticd" \ + 14 "Uninstall Meshtasticd" \ "" "" \ - 14 "Back to Main Menu" 3>&1 1>&2 2>&3) + 15 "Back to Main Menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -414,12 +438,16 @@ meshtasticd_settings() { fi case $option in - 1) #Get current configuration URL & QR code) + 1) #View node info) + dialog --no-collapse --infobox "Getting Node info..." 5 45 + dialog --no-collapse --colors --title "Node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0 + ;; + 2) #Get current configuration URL & QR code) dialog --no-collapse --infobox "Getting Meshtastic QR code and URL..." 5 45 femto-meshtasticd-config.sh -g pause ;; - 2) + 3) newurl=$(dialog --no-collapse --title "Meshtastic URL" --inputbox "New Meshtasticd URL (SHIFT+INS to paste):" 8 60 3>&1 1>&2 2>&3) if [ -n "$newurl" ]; then #if a URL was entered dialog --no-collapse --title "$title" --yesno "New Meshtasticd URL:\n$newurl\n\nConfirm?" 15 60 @@ -429,28 +457,28 @@ meshtasticd_settings() { fi fi ;; - 3) + 4) set_lora_radio ;; - 4) + 5) dialog --no-collapse --infobox "Getting admin keys..." 5 45 dialog --no-collapse --title "Admin keys" --msgbox "Up to 3 admin keys are permitted, more will be ignored.\n\nKeys:$(femto-meshtasticd-config.sh -v | tail -n 1 | sed 's/|n/\\n/g')" 0 0 ;; - 5) #set admin key) + 6) #set admin key) key=$(dialog --no-collapse --title "Meshtastic Admin Key" --inputbox "Meshtastic admin key - up to 3, more will be ignored.\n\n(SHIFT+INS to paste):" 11 40 3>&1 1>&2 2>&3) if [ -n "$key" ]; then #if a URL was entered femto-meshtasticd-config.sh -a "$key" pause fi ;; - 6) + 7) dialog --no-collapse --title "$title" --yesno "Meshtasticd can have up to 3 admin keys.\nClear admin key list?" 0 0 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -c pause fi ;; - 7) #legacy admin) + 8) #legacy admin) dialog --no-collapse --infobox "Getting current legacy admin state..." 5 45 state=$(sudo femto-meshtasticd-config.sh -p) if echo "$state" | grep -q "True"; then @@ -474,46 +502,46 @@ meshtasticd_settings() { esac done ;; - 8) #check meshtasticd service status) + 9) #check meshtasticd service status) dialog --no-collapse --infobox "Getting Meshtasticd service status..." 5 45 dialog --no-collapse --title "Meshtasticd service status" --msgbox "$(systemctl status meshtasticd)" 0 0 ;; - 9) #test mesh connectivity) + 10) #test mesh connectivity) dialog --no-collapse --title "Meshtastic connectivity test" --yesno "Will send \"test\" to channel 0 and wait for acknowledgement. Will try up to 3 times.\n\nPerform test?" 10 45 if [ $? -eq 0 ]; then #unless cancel/no dialog --no-collapse --infobox "Performing mesh connectivity test.\n\nThis may take a while..." 6 45 - dialog --no-collapse --title "Meshtasticd service status" --msgbox "$(femto-meshtasticd-config.sh -r)" 0 0 + dialog --no-collapse --colors --title "Meshtasticd service status" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -r)")" 0 0 fi ;; - 10) #start/restart meshtasticd) + 11) #start/restart meshtasticd) dialog --no-collapse --title "$title" --yesno "Start/restart Meshtasticd service?" 5 45 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -s dialog --no-collapse --msgbox "Meshtasticd service started/restarted." 5 45 fi ;; - 11) #stop meshtasticd) + 12) #stop meshtasticd) dialog --no-collapse --title "$title" --yesno "Stop Meshtasticd service?" 5 45 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -t dialog --no-collapse --msgbox "Meshtasticd service stopped." 5 45 fi ;; - 12) #Upgrade meshtasticd) + 13) #Upgrade meshtasticd) dialog --no-collapse --title "$title" --yesno "Upgrade Meshtasticd?\nRequires internet connection." 0 0 if [ $? -eq 0 ]; then #unless cancel/no femto-meshtasticd-config.sh -u pause fi ;; - 13) #uninstall meshtasticd) + 14) #uninstall meshtasticd) dialog --no-collapse --title "$title" --yesno "Uninstall Meshtasticd?\n\nFoxbuntu was designed with Meshtasticd integration in mind, and may behave unexpectedly if Meshtasticd is removed." 0 0 if [ $? -eq 0 ]; then femto-meshtasticd-config.sh -x dialog --no-collapse --msgbox "Meshtasticd uninstalled. To purge all remnants, run \`sudo apt purge\`.\nAfter reinstallation but before first launch, run the \"first boot script\" from the misc menu." 8 40 fi ;; - 14) + 15) return ;; esac diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh index 34c190a..6d8328e 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh @@ -77,18 +77,29 @@ while getopts ":higkl:q:va:cpo:sStruxm" opt; do ;; i) # Option -i (Get important node info) output=$(meshtastic --host --info) + preset_or_settings="Use preset? $(echo "$output" | grep -oP '"usePreset":\s*\K\w+')\n" + if echo "$output" | grep -qP '"usePreset":\s*true'; then + preset_or_settings+="Preset: $(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')" + else + preset_or_settings+="\ +Bandwidth: $(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')\n\ +Spread factor: $(echo "$output" | grep -oP '"spreadFactor":\s*\K\w+')\n\ +Coding rate: $(echo "$output" | grep -oP '"codingRate":\s*\K\w+')" + fi echo -e "\ Version: $(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)\n\ Node name: $(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)\n\ -NodeID: $(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)) ($(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))\n\ +NodeID: !$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)) (nodenum: $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))\n\ TX enabled? $(txEnabled=$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+'); [[ "$txEnabled" == "true" ]] && echo "\033[0;34menabled\033[0m" || echo "\033[0;31mdisabled\033[0m")\n\ Role: $(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)\n\ -Preset: $(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')\n\ +$preset_or_settings\n\ +Frequency offset: $(echo "$output" | grep -oP '"bandwidth":\s*\K\w+') Region: $(echo "$output" | grep -oP '"region":\s*"\K[^"]+')\n\ -$(channelNum=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1); [[ -n "$channelNum" && "$channelNum" -gt 0 ]] && echo -e "Frequency slot: $channelNum") -$(overrideFrequency=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+'); [[ -n "$overrideFrequency" && $(echo "$overrideFrequency > 0" | bc) -eq 1 ]] && echo -e "Override freq: $overrideFrequency")\n\ -Uptime: $(echo "$output" | grep -oP '"uptimeSeconds":\s*\K\d+' | head -n 1 | awk '{days=int($1/86400); hrs=int(($1%86400)/3600); mins=int(($1%3600)/60); secs=int($1%60); printf "%d days %02d:%02d:%02d\n", days, hrs, mins, secs}')\n\ -Public key: $(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)\ +Hop limit: $(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')\n\ +$(channelNum=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1); [[ -n "$channelNum" && "$channelNum" -gt 0 ]] && echo -e "Frequency slot: $channelNum\n")\ +$(overrideFrequency=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+'); [[ -n "$overrideFrequency" && $(echo "$overrideFrequency > 0" | bc) -eq 1 ]] && echo "Override freq: $overrideFrequency\n")\ +Public key: $(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)\n\ +Nodes in nodedb: $(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)\ " ;; g) # Option -g (get config URL) @@ -145,13 +156,13 @@ Public key: $(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head - r) # Option -r (mesh connectivity test) for ((i=0; i<=2; i++)); do if meshtastic --host --ch-index 0 --sendtext "test" --ack 2>/dev/null | grep -q "ACK"; then - echo "Received acknowledgement!" + echo -e "Received acknowledgement...\n\n\033[0;34mMesh connectivity confirmed!\033[0m" exit 0 else - echo "Retrying... ($((i + 1)))" + echo "No response, retrying... ($((i + 1)))" fi done - echo "Failed after 3 attempts." + echo -e "\033[0;31mFailed after 3 attempts.\033[0m" ;; s) # Option -s (start/restart Meshtasticd service) systemctl restart meshtasticd From 8db06901f83910131643b33942f47be99e4ce8d9 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 18 Jan 2025 01:04:10 +0200 Subject: [PATCH 5/8] More sysinfo stuff --- .../rootfs_uclibc_rv1106/usr/local/bin/femto-config | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index 6ca5aa8..d1b111d 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -206,8 +206,9 @@ logging() { # at some point this will be moved to a different script, and have many functions instead of one giant dump system_info() { - local cpu_architecture="armv7l (armhf 32bit)" - local cpu_model="Rockchip rv1103 (rev$(awk '/CPU revision/ {print $4}' /proc/cpuinfo))" + local cpu_architecture="$(uname -m) ($(dpkg --print-architecture) $(python3 -c "import platform; print(platform.architecture()[0])"))" + local cpu_model="$(dmesg | grep "soc_id" | sed -n 's/.*soc_id: //p')" + local cpu_temp="$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp) / 1000" | bc)°C" local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)" local cpu_speed="$(lscpu | grep "CPU min MHz" | awk '{print int($4)}') - $(lscpu | grep "CPU max MHz" | awk '{print int($4)}')mhz" local microsd_size="$(df -h / | awk 'NR==2 {printf "%s (%.0f%% free)", $4, (100 - $5+0)}')" @@ -236,7 +237,7 @@ system_info() { echo -e "\ Femtofox\n\ -Core: Luckfox Pico Mini\n\ +Core: $(cat /sys/firmware/devicetree/base/model)\n\ Operating System: $os_version\n\ Kernel version: $(uname -r)\n\ Uptime: $system_uptime\n\ @@ -249,8 +250,9 @@ K boot modules: $boot_modules\n\ Architecture: $cpu_architecture\n\ Model: $cpu_model\n\ Serial # $cpu_serial\n\ -Cores: 1\n\ +Cores: $(nproc)\n\ Speed: $cpu_speed\n\ +Temperature: $cpu_temp \n\ Storage:\n\ microSD size: $microsd_size\n\ From 9992c7ab4241d7ec4cca02cf1e249493c3cf791e Mon Sep 17 00:00:00 2001 From: Ruledo Date: Fri, 17 Jan 2025 23:26:47 -0800 Subject: [PATCH 6/8] Had to change avahi back to 80 temporarily 4403 is unreliable and I am guessing it's because we are on an old version of meshtastic. Will revisit this when we move to the meshtastic package repo. --- .../etc/avahi/services/meshtasticd.service | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/avahi/services/meshtasticd.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/avahi/services/meshtasticd.service index e0e3ece..8240266 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/avahi/services/meshtasticd.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/avahi/services/meshtasticd.service @@ -3,7 +3,7 @@ Meshtastic - _meshtastic._tcp - 4403 + _http._tcp + 80 - \ No newline at end of file + From de1e0009739b9babf093be9c14d68e5248c42c4d Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 18 Jan 2025 15:38:43 +0200 Subject: [PATCH 7/8] Increment foxbuntu release --- .../rootfs_uclibc_rv1106/etc/foxbuntu-release | 6 ++--- .../usr/local/bin/femto-software.sh | 26 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release index 8cdb706..dfde80b 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release @@ -1,6 +1,6 @@ major=0 -minor=96 -patch=1 +minor=97 +patch=0 hotfix= -# major, minor and patch must be numbers. hotfix must be letters. \ No newline at end of file +# major, minor and patch must be numbers and populated. hotfix must be letters and can be blank. diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index ac32818..4ed1a53 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -4,7 +4,7 @@ title="Software Manager" package_dir="/usr/local/bin/packages" install() { - dialog --title "$title" --yesno "\nInstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40 + dialog --no-collapse --title "$title" --yesno "\nInstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -17,14 +17,14 @@ install() { #output=$(echo -e "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful - dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks else - dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks fi } uninstall() { - dialog --title "$title" --yesno "\nUninstall $1\n\nProceed?" 10 40 + dialog --no-collapse --title "$title" --yesno "\nUninstall $1\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -34,14 +34,14 @@ uninstall() { user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present #output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful - dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo -e "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo -e "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks else - dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks fi } upgrade() { - dialog --title "$title" --yesno "\nUpgrade $1\n\nProceed?" 10 40 + dialog --no-collapse --title "$title" --yesno "\nUpgrade $1\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -51,9 +51,9 @@ upgrade() { user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful - dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks else - dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks fi } @@ -63,7 +63,7 @@ upgrade() { package_intro() { echo "Loading package info..." # check if each field in the package info is supported by the package, and if so get it and insert it into the package info dialog - dialog --colors --title "$title" --msgbox "\ + dialog --no-collapse --colors --title "$title" --msgbox "\ $($package_dir/$1.sh -N)\n\ $(if $package_dir/$1.sh -O | grep -q 'A'; then echo -e "by $($package_dir/$1.sh -A)"; fi)\n\ $(if $package_dir/$1.sh -O | grep -q 'D'; then echo "\n$($package_dir/$1.sh -D)"; fi)\n\ @@ -80,7 +80,7 @@ package_menu() { while true; do echo "Loading package menu..." # for each line, check if it's supported by the package, display it if the current install state of the package is appropriate (example: don't display "install" if the package is already installed, don't display "stop service" for a package with no services) - choice=$(dialog --title "$title" --cancel-label "Back" --menu "$($package_dir/$1.sh -N)" 17 45 5 \ + choice=$(dialog --no-collapse --title "$title" --cancel-label "Back" --menu "$($package_dir/$1.sh -N)" 17 45 5 \ $(if $package_dir/$1.sh -O | grep -q 'l' && $package_dir/$1.sh -I; then echo "Run software x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'i' && ! $package_dir/$1.sh -I; then echo "Install x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'u' && $package_dir/$1.sh -I; then echo "Uninstall x"; fi) \ @@ -109,7 +109,7 @@ package_menu() { "Disable service") eval "$package_dir/$1.sh -d" ;; "Stop service") eval "$package_dir/$1.sh -s" ;; "Start/restart service") eval "$package_dir/$1.sh -r" ;; - "Get service status") dialog --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;; + "Get service status") dialog --no-collapse --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;; "Back to software manager") break ;; esac done @@ -119,7 +119,7 @@ package_menu() { while true; do title="$title" option="" - option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \ + option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 0 0 6 \ 1 "The Comms Channel BBS, TC²BBS" \ 2 "Contact (Meshtastic client)" \ 3 "Meshing Around by Spud" \ From 11e5a7b05532efbfe9374cb29b1716c4b54ebda8 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 18 Jan 2025 17:07:02 +0200 Subject: [PATCH 8/8] Change ram utilization method and microsd free space method to align with htop --- .../rootfs_uclibc_rv1106/usr/local/bin/femto-config | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index d1b111d..93201b3 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -210,10 +210,10 @@ system_info() { local cpu_model="$(dmesg | grep "soc_id" | sed -n 's/.*soc_id: //p')" local cpu_temp="$(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp) / 1000" | bc)°C" local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)" - local cpu_speed="$(lscpu | grep "CPU min MHz" | awk '{print int($4)}') - $(lscpu | grep "CPU max MHz" | awk '{print int($4)}')mhz" - local microsd_size="$(df -h / | awk 'NR==2 {printf "%s (%.0f%% free)", $4, (100 - $5+0)}')" - local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}')" - local swap="$(free -m | awk 'NR==3{printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}')" + local cpu_speed="$(lscpu | grep "CPU min MHz" | awk '{print int($4)}')-$(lscpu | grep "CPU max MHz" | awk '{print int($4)}')mhz" + local microsd_size="$(df --block-size=1 / | awk 'NR==2 {total=$2; avail=$4; total_human=sprintf("%.2f", total/1024/1024/1024); avail_human=sprintf("%.2f", avail/1024/1024/1024); printf "%.2f GB (%.2f%% free)", total_human, (avail/total)*100}')" + local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)\n", $2, 100 - (($3/$2)*100)}')" + local swap="$(free -m | awk 'NR==3 {if ($2 > 1000) {printf "%.2f GB (%.2f%% free)", $2/1024, ($4/$2)*100} else {printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}}')" local mounted_drives="$([ "$(for dir in /mnt/*/; do echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "Mounted drives: $(for dir in /mnt/*; do echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')")" local os_version="Foxbuntu v$(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release)$(output=$(grep -o 'patch=[1-9][0-9]*' /etc/foxbuntu-release | cut -d= -f2) && [ -n "$output" ] && echo ".$output")$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release) ($(lsb_release -d | awk -F'\t' '{print $2}') $(lsb_release -c | awk -F'\t' '{print $2}'))" local system_uptime="$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')" @@ -250,8 +250,7 @@ K boot modules: $boot_modules\n\ Architecture: $cpu_architecture\n\ Model: $cpu_model\n\ Serial # $cpu_serial\n\ -Cores: $(nproc)\n\ -Speed: $cpu_speed\n\ +Speed: $cpu_speed x $(nproc) cores\n\ Temperature: $cpu_temp \n\ Storage:\n\