mirror of
https://github.com/femtofox/femtofox.git
synced 2026-10-26 02:49:05 -04:00
Merge pull request #268 from femtofox/new_working
Refactor data supply and ingestion for UIs
This commit is contained in:
commit
9c24fa12c5
10 changed files with 376 additions and 333 deletions
|
|
@ -8,7 +8,7 @@
|
|||
# /usr/local/bin/femto-runonce.sh
|
||||
#fi
|
||||
|
||||
luckfox-config load
|
||||
#luckfox-config load
|
||||
|
||||
# try enable RTC
|
||||
echo 'ds1307 0x68' | sudo tee /sys/class/i2c-adapter/i2c-3/new_device > /dev/null 2>&1
|
||||
|
|
|
|||
30
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc
Normal file
30
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# Run-time configuration file for dialog
|
||||
#
|
||||
# Automatically generated by "dialog --create-rc <file>"
|
||||
#
|
||||
#
|
||||
# Types of values:
|
||||
#
|
||||
# Number - <number>
|
||||
# String - "string"
|
||||
# Boolean - <ON|OFF>
|
||||
# Attribute - (foreground,background,highlight?,underline?,reverse?)
|
||||
|
||||
# Up arrow color
|
||||
uarrow_color = (GREEN,WHITE,ON)
|
||||
|
||||
# Down arrow color
|
||||
darrow_color = uarrow_color
|
||||
|
||||
# Active form text color
|
||||
form_active_text_color = button_active_color
|
||||
|
||||
# Form text color
|
||||
form_text_color = (WHITE,CYAN,ON)
|
||||
|
||||
# Readonly form item color
|
||||
form_item_readonly_color = (BLUE,WHITE,ON)
|
||||
|
||||
# Item help-text color
|
||||
itemhelp_color = (BLACK,BLUE,OFF)
|
||||
|
|
@ -37,14 +37,61 @@ loading() {
|
|||
dialog --no-collapse --infobox "$1" 5 45
|
||||
}
|
||||
|
||||
## function to pull data from various femto scripts and convert it to the contents of a read only dialog --form
|
||||
# ingest_data() { # usage: `ingest_data "command.sh -argument" key_width value_width`
|
||||
# unset output_array #debug code, delete me
|
||||
# declare -a output_array
|
||||
# # Read the output from femto-meshtasticd-config.sh and store it in the array
|
||||
# while IFS=':' read -r key value; do
|
||||
# # Trim leading/trailing spaces from key and value
|
||||
# key=$(echo "$key" | xargs)
|
||||
# value=$(echo "$value" | xargs)
|
||||
# output_array+=("$key=$value") # Use indexed array to preserve order
|
||||
# done < <(eval $1)
|
||||
# form_contents=""
|
||||
# i=1
|
||||
# for pair in "${output_array[@]}"; do
|
||||
# key=$(cut -d'=' -f1 <<< "$pair")
|
||||
# value=$(cut -d'=' -f2- <<< "$pair")
|
||||
# form_contents+="\"$key\" $i 1 \"$value\" $i $2 $3 -1 "
|
||||
# ((i++))
|
||||
# done
|
||||
# echo "$form_contents" | sed 's/\x1b\[[0-9;]*m//g'
|
||||
# }
|
||||
## CODE TO USE THIS FUNCTION:
|
||||
# eval "$(echo -e "dialog --no-collapse --no-cancel --form \"Meshtastic node info\" 0 0 0 $(ingest_data "femto-meshtasticd-config.sh -i" 18 0) 2>/dev/null")"
|
||||
|
||||
|
||||
# function to pull data from various femto scripts and convert it a simple text string, with dialog colors
|
||||
ingest_data() { # usage: `ingest_data "command.sh -argument" key_width`
|
||||
local output_string=""
|
||||
# Read the output from femto-meshtasticd-config.sh and store output_string
|
||||
while IFS=':' read -r key value; do
|
||||
# Trim leading/trailing spaces from key and value
|
||||
key=$(replace_colors "$(echo "$key" | xargs)")
|
||||
value=$(replace_colors "$(echo "$value" | xargs)")
|
||||
if [[ -z "$key" && -z "$value" ]]; then
|
||||
output_string+="---\n"
|
||||
else
|
||||
output_string+=$(printf "%s:%*s%s\n" "$key" $(($2 - 1 - ${#key})) "" "$value\n") # save the key and value to the output_string, adding padding between them as determined by `$2 - 1 - key-length` The 1 accounts for the :
|
||||
fi
|
||||
done < <(eval $1)
|
||||
echo -e "$output_string"
|
||||
}
|
||||
|
||||
wifi_config() {
|
||||
local wifi_ssid=""
|
||||
local wifi_psk=""
|
||||
local wifi_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\""
|
||||
local title2="Wi-Fi (wlan0) Settings"
|
||||
local config=$(dialog --no-collapse --title "$title2" --form "↑ ↓ to navigate, [ESC] to cancel." 10 45 0 \
|
||||
"SSID:" 1 1 "$(grep -oP '^ *ssid="\K[^"]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 1 15 24 32\
|
||||
"Password:" 2 1 "" 2 15 24 64\
|
||||
"Country Code:" 3 1 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3 15 24 2\
|
||||
3>&1 1>&2 2>&3)
|
||||
# Parse the output
|
||||
wifi_ssid=$(echo "$config" | sed -n '1p')
|
||||
wifi_psk=$(echo "$config" | sed -n '2p')
|
||||
wifi_country=$(echo "$config" | sed -n '3p')
|
||||
|
||||
cmd="femto-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\"" # build the wifi setting command to send to the network config script
|
||||
[ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\""
|
||||
cmd="$cmd -r"
|
||||
if [ -z "$wifi_ssid" ]; then
|
||||
|
|
@ -63,41 +110,32 @@ wifi_config() {
|
|||
networking_settings() {
|
||||
local title="Networking"
|
||||
local title2="Wi-Fi (wlan0) Settings"
|
||||
ip=$(hostname -I | sed 's/ / /g'); ip=${ip:+$(printf "IPv4 address:\n%s" "$ip")}
|
||||
wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf"
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
networking_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$networking_choice" --title "$title" --menu "$ip" $([ -z "$ip" ] && echo 16 || echo 18) 40 4 \
|
||||
1 "Turn Wi-Fi on/off" \
|
||||
2 "View Wi-Fi settings" \
|
||||
3 "Change Wi-Fi settings" \
|
||||
4 "View ethernet settings" \
|
||||
5 "Restart networking" \
|
||||
6 "Set hostname" \
|
||||
7 "Test internet connection" \
|
||||
" " "" \
|
||||
8 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
networking_choice=$(dialog --no-collapse --cancel-label "Back" --backtitle "IPv4 address: $(femto-network-config.sh -i)" --default-item "$networking_choice" --title "$title" --item-help --menu "" 16 40 4 \
|
||||
1 "Turn Wi-Fi on/off" "" \
|
||||
2 "View Wi-Fi settings" "" \
|
||||
3 "Change Wi-Fi settings" "" \
|
||||
4 "View ethernet settings" "" \
|
||||
5 "Restart networking" "" \
|
||||
6 "Set hostname" "" \
|
||||
7 "Test internet connection" "" \
|
||||
" " "" "" \
|
||||
8 "Back to main menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $networking_choice in
|
||||
1) # Turn Wi-Fi on/off)
|
||||
if ! ip link show wlan0 &>/dev/null; then
|
||||
dialog --no-collapse --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 Wi-Fi adapter connected?" 8 40
|
||||
else
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Enable/disable Wi-Fi" --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \
|
||||
1 "Turn Wi-Fi on" \
|
||||
2 "Turn Wi-Fi off" \
|
||||
" " "" \
|
||||
3 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Enable/disable Wi-Fi" --item-help --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \
|
||||
1 "Turn Wi-Fi on" "" \
|
||||
2 "Turn Wi-Fi off" "" \
|
||||
" " "" "" \
|
||||
3 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) femto-network-config.sh -x "up" && break ;;
|
||||
2) femto-network-config.sh -x "down" && break ;;
|
||||
|
|
@ -108,14 +146,14 @@ networking_settings() {
|
|||
;;
|
||||
2) # View Wi-Fi settings)
|
||||
echo "Getting Wi-Fi configuration..."
|
||||
dialog --no-collapse --title "$title2" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -w)")" 0 0
|
||||
dialog --no-collapse --title "$title2" --colors --msgbox "$(ingest_data "femto-network-config.sh -w" 15)" 0 0
|
||||
;;
|
||||
3) # Change Wi-Fi settings)
|
||||
wifi_config
|
||||
;;
|
||||
4) # View ethernet settings)
|
||||
echo "Getting ethernet configuration..."
|
||||
dialog --no-collapse --title "Ethernet (eth0) settings" --colors --msgbox "$(echo -e "$(replace_colors "$(femto-network-config.sh -e)")")" 0 0
|
||||
dialog --no-collapse --title "Ethernet (eth0) settings" --colors --msgbox "$(ingest_data "femto-network-config.sh -e" 15)" 0 0
|
||||
;;
|
||||
5) # Restart networking)
|
||||
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
|
||||
|
|
@ -124,7 +162,7 @@ networking_settings() {
|
|||
fi
|
||||
;;
|
||||
6) # set hostname)
|
||||
new_hostname=$(dialog --no-collapse --title "$title" --inputbox "Enter new hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3)
|
||||
new_hostname=$(dialog --no-collapse --title "$title" --max-input 253 --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 --no-collapse --title "$title" --msgbox "Femtofox is now reachable at\n$new_hostname.local" 8 40
|
||||
|
|
@ -143,42 +181,38 @@ networking_settings() {
|
|||
|
||||
# utilities
|
||||
utilities() {
|
||||
local title="Utilities"
|
||||
local title="Utilities & Tools"
|
||||
while true; do
|
||||
utilities_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$utilities_choice" --menu "$title" 21 50 4 \
|
||||
1 "View 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 "Disable/enable activity LED" \
|
||||
10 "Reboot" \
|
||||
11 "Shutdown" \
|
||||
" " "" \
|
||||
12 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
utilities_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$utilities_choice" --item-help --menu "$title" 21 50 4 \
|
||||
1 "View 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 "Disable/enable activity LED" "" \
|
||||
10 "Reboot" "" \
|
||||
11 "Shutdown" "" \
|
||||
" " "" "" \
|
||||
12 "Back to main menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
|
||||
case $utilities_choice in
|
||||
1)
|
||||
1) #sysinfo)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --menu "System info" 17 40 5 \
|
||||
1 "CPU" \
|
||||
2 "Operating system" \
|
||||
3 "Storage & memory" \
|
||||
4 "Peripherals & devices" \
|
||||
5 "Networking" \
|
||||
6 "Meshtastic node info" \
|
||||
7 "Complete system info" \
|
||||
" " "" \
|
||||
8 "Back to previous menu" 3>&1 1>&2 2>&3)
|
||||
choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --item-help --menu "System info" 17 40 5 \
|
||||
1 "CPU" "" \
|
||||
2 "Operating system" "" \
|
||||
3 "Storage & memory" "" \
|
||||
4 "Peripherals & devices" ""\
|
||||
5 "Networking" "" \
|
||||
6 "Meshtastic node info" "" \
|
||||
7 "Complete system info" "" \
|
||||
" " "" "" \
|
||||
8 "Back to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
|
|
@ -188,31 +222,49 @@ utilities() {
|
|||
case $choice in
|
||||
1) # CPU)
|
||||
loading "Loading CPU info..."
|
||||
dialog --no-collapse --colors --title "CPU info" --msgbox "$(replace_colors "$(femto-utils.sh -c)")" 0 0
|
||||
dialog --no-collapse --colors --title "CPU info" --msgbox "$(ingest_data "femto-utils.sh -c" 15)" 0 0
|
||||
;;
|
||||
2) # Operating system)
|
||||
loading "Loading operating system info..."
|
||||
dialog --no-collapse --colors --extra-button --title "Operating system" --msgbox "$(replace_colors "$(femto-utils.sh -o)")" 0 0
|
||||
dialog --no-collapse --colors --title "Operating system info" --msgbox "$(ingest_data "femto-utils.sh -o" 15)" 0 0
|
||||
;;
|
||||
3) # Storage & memory)
|
||||
loading "Loading storage & memory info..."
|
||||
dialog --no-collapse --colors --title "Storage & memory" --msgbox "$(replace_colors "$(femto-utils.sh -S)")" 0 0
|
||||
dialog --no-collapse --colors --title "Storage & memory info" --msgbox "$(ingest_data "femto-utils.sh -S" 15)" 0 0
|
||||
;;
|
||||
4) # Peripherals & devices)
|
||||
loading "Loading peripherals & devices info..."
|
||||
dialog --no-collapse --colors --title "Peripherals & devices" --msgbox "$(replace_colors "$(femto-utils.sh -p)")" 0 0
|
||||
dialog --no-collapse --colors --title "Peripherals & devices info" --msgbox "$(ingest_data "femto-utils.sh -p" 15)" 0 0
|
||||
;;
|
||||
5) # Networking)
|
||||
loading "Loading networking info..."
|
||||
dialog --no-collapse --colors --title "Networking" --msgbox "$(replace_colors "$(femto-utils.sh -n)")" 0 0
|
||||
dialog --no-collapse --colors --title "Networking info" --msgbox "$(ingest_data "femto-utils.sh -n" 15)" 0 0
|
||||
;;
|
||||
6) # Meshtastic node info)
|
||||
loading "Loading Meshtastic node info..."
|
||||
dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0
|
||||
dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
|
||||
;;
|
||||
7) # Complete system info)
|
||||
loading "Loading complete system info..."
|
||||
dialog --no-collapse --colors --title "System info" --msgbox "$(replace_colors "$(femto-utils.sh -i)")" 0 0
|
||||
dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "\
|
||||
Femtofox
|
||||
CPU:
|
||||
$(ingest_data "femto-utils.sh -c" 15)
|
||||
|
||||
Operating System:
|
||||
$(ingest_data "femto-utils.sh -o" 15)
|
||||
|
||||
Storage:
|
||||
$(ingest_data "femto-utils.sh -S" 15)
|
||||
|
||||
Networking (wlan0 & eth0):
|
||||
$(ingest_data "femto-utils.sh -p" 15)
|
||||
|
||||
Peripherals:
|
||||
$(ingest_data "femto-utils.sh -n" 15)
|
||||
|
||||
Meshtasticd:
|
||||
$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
|
||||
;;
|
||||
8) break ;;
|
||||
esac
|
||||
|
|
@ -237,15 +289,12 @@ utilities() {
|
|||
8) # logging)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(femto-utils.sh -l "check")")" 14 50 2 \
|
||||
1 "Enable (default)" \
|
||||
2 "Disable" \
|
||||
" " "" \
|
||||
3 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --item-help --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(femto-utils.sh -l "check")")" 14 50 2 \
|
||||
1 "Enable (default)" "" \
|
||||
2 "Disable" "" \
|
||||
" " "" "" \
|
||||
3 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) femto-utils.sh -l "enable" ;;
|
||||
2) femto-utils.sh -l "disable" ;;
|
||||
|
|
@ -256,15 +305,12 @@ utilities() {
|
|||
9) # logging)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --menu "Before deploying a Femtofox, it is advisable to disable the Activity LED to save power.\nCurrent state: $(replace_colors "$(femto-utils.sh -a "check")")" 14 50 2 \
|
||||
1 "Enable (default)" \
|
||||
2 "Disable" \
|
||||
" " "" \
|
||||
3 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --item-help --menu "Before deploying a Femtofox, it is advisable to disable the Activity LED to save power.\nCurrent state: $(replace_colors "$(femto-utils.sh -a "check")")" 14 50 2 \
|
||||
1 "Enable (default)" "" \
|
||||
2 "Disable" "" \
|
||||
" " "" "" \
|
||||
3 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) femto-utils.sh -a "enable" ;;
|
||||
2) femto-utils.sh -a "disable" ;;
|
||||
|
|
@ -297,23 +343,18 @@ set_lora_radio() {
|
|||
while true; do
|
||||
echo "Checking LoRa radio..."
|
||||
#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, -))
|
||||
choice=$(dialog --no-collapse --colors --cancel-label "Back" --default-item "$choice" --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 '^ ()$')" 19 50 10 \
|
||||
"Ebyte e22-900m30s" "(SX1262_TCXO)" \
|
||||
"Ebyte e22-900m22s" "(SX1262_TCXO)"\
|
||||
"Ebyte e80-900m22s" "(SX1262_XTAL)"\
|
||||
"Heltec ht-ra62" "(SX1262_TCXO)"\
|
||||
"Seeed wio-sx1262" "(SX1262_TCXO)"\
|
||||
"Waveshare sx126x-xxxm" "(SX1262_XTAL)"\
|
||||
"AI Thinker ra-01sh" "(SX1262_XTAL)"\
|
||||
"None" "(simulated radio)"\
|
||||
" " "" \
|
||||
"Skip" "" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
choice=$(dialog --no-collapse --colors --cancel-label "Back" --default-item "$choice" --title "Meshtastic LoRa radio" --item-help --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 '^ ()$')" 19 50 10 \
|
||||
"Ebyte e22-900m30s" "(SX1262_TCXO)" "" \
|
||||
"Ebyte e22-900m22s" "(SX1262_TCXO)" "" \
|
||||
"Ebyte e80-900m22s" "(SX1262_XTAL)" "" \
|
||||
"Heltec ht-ra62" "(SX1262_TCXO)" "" \
|
||||
"Seeed wio-sx1262" "(SX1262_TCXO)" "" \
|
||||
"Waveshare sx126x-xxxm" "(SX1262_XTAL)" "" \
|
||||
"AI Thinker ra-01sh" "(SX1262_XTAL)" "" \
|
||||
"None" "(simulated radio)" "" \
|
||||
" " "" "" \
|
||||
"Skip" "" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
local radio=""
|
||||
case $choice in
|
||||
"Ebyte e22-900m30s")
|
||||
|
|
@ -356,28 +397,23 @@ meshtastic_settings() {
|
|||
local title="Meshtastic Settings"
|
||||
while true; do
|
||||
echo "Checking Meshtasticd service state..."
|
||||
meshtastic_choice=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --default-item "$meshtastic_choice" --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Warning: using simulated radio\Zn')" 19 50 4 \
|
||||
1 "View node info" \
|
||||
2 "View configuration URL & QR code" \
|
||||
3 "Set new configuration URL" \
|
||||
4 "Set LoRa radio" \
|
||||
5 "Security settings" \
|
||||
6 "Mesh connectivity test" \
|
||||
7 "Manage Meshtasticd service" \
|
||||
8 "Upgrade/install Meshtasticd" \
|
||||
9 "Uninstall Meshtasticd" \
|
||||
" " "" \
|
||||
10 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
meshtastic_choice=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --default-item "$meshtastic_choice" --item-help --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Warning: using simulated radio\Zn')" 20 50 4 \
|
||||
1 "View node info" "" \
|
||||
2 "View configuration URL & QR code" "" \
|
||||
3 "Set new configuration URL" "" \
|
||||
4 "Set LoRa radio" "" \
|
||||
5 "Security settings" "" \
|
||||
6 "Mesh connectivity test" "" \
|
||||
7 "Manage Meshtasticd service" "" \
|
||||
8 "Upgrade/install Meshtasticd" "" \
|
||||
9 "Uninstall Meshtasticd" "" \
|
||||
" " "" "" \
|
||||
10 "Back to main menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $meshtastic_choice in
|
||||
1) # view node info)
|
||||
loading "Getting node info..."
|
||||
dialog --no-collapse --colors --title "Node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0
|
||||
dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
|
||||
;;
|
||||
2) # get current configuration URL & QR code)
|
||||
loading "Getting Meshtastic QR code and URL..."
|
||||
|
|
@ -400,20 +436,17 @@ meshtastic_settings() {
|
|||
5) # remote admin)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Meshtastic Security Settings" --menu "" 16 40 5 \
|
||||
1 "View/change public key" \
|
||||
2 "View/change private key" \
|
||||
" " "" \
|
||||
3 "View admin keys" \
|
||||
4 "Set admin key" \
|
||||
5 "Clear admin keys" \
|
||||
6 "Legacy admin channel" \
|
||||
" " "" \
|
||||
7 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Meshtastic Security Settings" --item-help --menu "" 16 40 5 \
|
||||
1 "View/change public key" "" \
|
||||
2 "View/change private key" "" \
|
||||
" " "" "" \
|
||||
3 "View admin keys" "" \
|
||||
4 "Set admin key" "" \
|
||||
5 "Clear admin keys" "" \
|
||||
6 "Legacy admin channel" "" \
|
||||
" " "" "" \
|
||||
7 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) # view/change public key)
|
||||
loading "Getting current public key..."
|
||||
|
|
@ -469,15 +502,12 @@ meshtastic_settings() {
|
|||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
loading "Getting current legacy admin state..."
|
||||
choice=$(dialog --no-collapse --colors --title "Legacy Admin" --default-item "$choice" --menu "Current state: $(replace_colors "$(femto-meshtasticd-config.sh -p)")" 12 40 5 \
|
||||
1 "Enable" \
|
||||
2 "Disable (default)" \
|
||||
" " "" \
|
||||
3 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --colors --title "Legacy Admin" --default-item "$choice" --item-help --menu "Current state: $(replace_colors "$(femto-meshtasticd-config.sh -p)")" 12 40 5 \
|
||||
1 "Enable" "" \
|
||||
2 "Disable (default)" "" \
|
||||
" " "" "" \
|
||||
3 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) # enable legacy admin)
|
||||
dialog --no-collapse --title "Legacy Admin" --yesno "Enable legacy admin channel?\n" 0 0
|
||||
|
|
@ -525,10 +555,7 @@ meshtastic_settings() {
|
|||
$(if echo "$service_state" | grep -q 'enabled'; then echo "Disable service x"; fi) \
|
||||
" " " " \
|
||||
"Back to previous menu" "x" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
"View detailed service status")
|
||||
loading "Getting Meshtasticd service status..."
|
||||
|
|
@ -591,22 +618,17 @@ meshtastic_settings() {
|
|||
help_menu() {
|
||||
while true; do
|
||||
local title="Help / About"
|
||||
help_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$help_choice" --menu "$title" 0 0 7 \
|
||||
1 "About Femtofox" \
|
||||
2 "Display pinout" \
|
||||
3 "Femtofox licensing info - short" \
|
||||
4 "Femtofox licensing info - long" \
|
||||
5 "Meshtastic licensing info" \
|
||||
6 "About Luckfox" \
|
||||
7 "About Ubuntu" \
|
||||
" " "" \
|
||||
8 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
help_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$help_choice" --item-help --menu "$title" 0 0 7 \
|
||||
1 "About Femtofox" "" \
|
||||
2 "Display pinout" "" \
|
||||
3 "Femtofox licensing info - short" "" \
|
||||
4 "Femtofox licensing info - long" "" \
|
||||
5 "Meshtastic licensing info" "" \
|
||||
6 "About Luckfox" "" \
|
||||
7 "About Ubuntu" "" \
|
||||
" " "" "" \
|
||||
8 "Back to main menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $help_choice in
|
||||
1) #About Femtofox)
|
||||
dialog --no-collapse --title "About Femtofox" --default-item "$choice" --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
|
||||
|
|
@ -614,20 +636,14 @@ help_menu() {
|
|||
2) #Display pinout)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --menu "Pinouts" 15 40 5 \
|
||||
1 "Femtofox Pro/CE" \
|
||||
2 "Femtofox Zero" \
|
||||
3 "Femtofox Tiny" \
|
||||
4 "Luckfox Pico Mini" \
|
||||
" " "" \
|
||||
5 "Back to Help Menu" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --item-help --menu "Pinouts" 15 40 5 \
|
||||
1 "Femtofox Pro/CE" "" \
|
||||
2 "Femtofox Zero" "" \
|
||||
3 "Femtofox Tiny" "" \
|
||||
4 "Luckfox Pico Mini" "" \
|
||||
" " "" "" \
|
||||
5 "Back to Help Menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
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 ;;
|
||||
|
|
@ -684,28 +700,20 @@ while getopts ":hlwL:i" opt; do
|
|||
;;
|
||||
esac
|
||||
done
|
||||
if [ -n "$1" ]; then
|
||||
exit
|
||||
fi
|
||||
[ -n "$1" ] && exit # if there were arguments, exit before loading the menu
|
||||
|
||||
# Main menu
|
||||
while true; do
|
||||
main_menu_choice=$(dialog --no-collapse --cancel-label "Exit" --default-item "$main_menu_choice" --menu "Femtofox Config" 16 40 5 \
|
||||
1 "Settings wizard" \
|
||||
2 "Networking" \
|
||||
3 "Meshtastic" \
|
||||
4 "Software manager" \
|
||||
5 "Utilities" \
|
||||
6 "Help" \
|
||||
" " "" \
|
||||
7 "Exit" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
main_menu_choice=$(dialog --no-collapse --cancel-label "Exit" --default-item "$main_menu_choice" --item-help --menu "Femtofox Config" 16 40 5 \
|
||||
1 "Settings wizard" "" \
|
||||
2 "Networking" "" \
|
||||
3 "Meshtastic" "" \
|
||||
4 "Software manager" "" \
|
||||
5 "Utilities & tools" "" \
|
||||
6 "Help" "" \
|
||||
" " "" "" \
|
||||
7 "Exit" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $main_menu_choice in
|
||||
1) femto-install-wizard.sh ;;
|
||||
2) networking_settings ;;
|
||||
|
|
@ -717,4 +725,4 @@ while true; do
|
|||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
|
@ -81,32 +81,46 @@ while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do
|
|||
echo -e "$help"
|
||||
;;
|
||||
i) # Option -i (Get important node info)
|
||||
declare -a output_array
|
||||
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+')"
|
||||
output_array+=("Service=$(femto-meshtasticd-config.sh -S)")
|
||||
output_array+=("Version=$(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)")
|
||||
output_array+=("Node name=$(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)")
|
||||
output_array+=("NodeID=$(echo "!$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))")")
|
||||
output_array+=("Nodenum=$(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)")
|
||||
output_array+=("TX enabled=$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+')")
|
||||
use_preset=$(echo "$output" | grep -oP '"usePreset":\s*\K\w+')
|
||||
output_array+=("Use preset=$use_preset")
|
||||
if [ "$use_preset" = "true" ]; then # if use-preset is true, then display the preset
|
||||
output_array+=("Preset=$(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')")
|
||||
else # otherwise, display the lora settings
|
||||
output_array+=("Bandwidth=$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')")
|
||||
output_array+=("Spread factor=$(echo "$output" | grep -oP '"spreadFactor":\s*\K\w+')")
|
||||
output_array+=("Coding rate=$(echo "$output" | grep -oP '"codingRate":\s*\K\w+')")
|
||||
fi
|
||||
echo -e "\
|
||||
Service status: $(femto-meshtasticd-config.sh -S)\n\
|
||||
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)) (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_or_settings\n\
|
||||
Frequency offset: $(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')
|
||||
Region: $(echo "$output" | grep -oP '"region":\s*"\K[^"]+')\n\
|
||||
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)\
|
||||
"
|
||||
output_array+=("Role=$(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)")
|
||||
freq_offset=$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')
|
||||
if [ "$freq_offset" != 0 ]; then # only display frequency offset if not 0
|
||||
output_array+=("Override freq=$freq_offset")
|
||||
fi
|
||||
output_array+=("Region=$(echo "$output" | grep -oP '"region":\s*"\K[^"]+')")
|
||||
output_array+=("Hop limit=$(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')")
|
||||
freq_slot=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1)
|
||||
if [ "$freq_slot" != 0 ]; then # only display frequency slot if not 0
|
||||
freq_slot+=("Freq slot=$freq_slot")
|
||||
fi
|
||||
override_freq=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+')
|
||||
if [ "$override_freq" != "0" ]; then # only display override frequency if not 0
|
||||
output_array+=("Override freq=$override_freq")
|
||||
fi
|
||||
output_array+=("Public key=$(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)")
|
||||
output_array+=("Nodes in db=$(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)")
|
||||
# now, echo the array
|
||||
for pair in "${output_array[@]}"; do
|
||||
key=$(echo "$pair" | cut -d'=' -f1)
|
||||
value=$(echo "$pair" | cut -d'=' -f2-)
|
||||
echo "$key:$value"
|
||||
done
|
||||
;;
|
||||
g) # Option -g (get config URL)
|
||||
url=$(meshtastic --host --qr-all | grep -oP '(?<=Complete URL \(includes all channels\): )https://[^ ]+') #add look for errors
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ Options are:
|
|||
-c "COUNTRY" Set Wi-Fi 2-letter country code (such as US, DE)
|
||||
-r Restart Wi-Fi
|
||||
-e Get ethernet settings
|
||||
-i Get IPv4 addresses
|
||||
-w Get Wi-Fi settings
|
||||
-n "HOSTNAME" Change hostname
|
||||
-t Test internet connection
|
||||
|
|
@ -37,7 +38,7 @@ if [ $# -eq 0 ]; then
|
|||
fi
|
||||
|
||||
# Parse options
|
||||
while getopts ":hx:Ts:p:c:ewn:tr" opt; do
|
||||
while getopts ":hx:Ts:p:c:eiwn:tr" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
|
|
@ -77,42 +78,52 @@ 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 "\
|
||||
Eth status:$([ "$status" == "UP" ] && echo -e "\033[4m\033[0;34mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")"
|
||||
if [ "$status" == "UP" ]; then
|
||||
echo "IPv4 Address: $(ifconfig eth0 | grep 'inet ' | awk '{print $2}')\n\
|
||||
IPv6 Address: $(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')"
|
||||
echo -e "\
|
||||
IPv4 Address:$(ifconfig eth0 | grep 'inet ' | awk '{print $2}')
|
||||
IPv6 Address:$(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')"
|
||||
fi
|
||||
echo -e "MAC 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)
|
||||
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)"
|
||||
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"
|
||||
mac_address_line="\
|
||||
MAC address:$(ifconfig wlan0 | grep ether | awk '{print $2}')"
|
||||
if [ "$(cat /etc/wifi_state.txt)" = "up" ]; then
|
||||
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\
|
||||
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\
|
||||
Sig. 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
|
||||
echo -e "Wi-Fi status: \033[0;31mdisabled\033[0m\n\
|
||||
echo -e "\
|
||||
Wi-Fi status:\033[0;31mdisabled\033[0m\n\
|
||||
\n\
|
||||
$wifi_settings"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "Wi-Fi status: \033[0;31mwlan0 not detected\033[0m\n\
|
||||
echo -e "\
|
||||
Wi-Fi status:\033[0;31mwlan0 not detected\033[0m\n\
|
||||
\n\
|
||||
Wi-Fi settings:\n\
|
||||
$wifi_settings"
|
||||
fi
|
||||
;;
|
||||
i) # Option -i (Get all IPv4 addresses)
|
||||
hostname -I | awk '{for(i=1; i<=NF; i++) {if(i>1) printf ", "; printf $i} print ""}'
|
||||
;;
|
||||
t) # Option -t (test internet connection)
|
||||
# Define ping targets and initialize counter
|
||||
targets=("1.1.1.1" "8.8.8.8")
|
||||
|
|
@ -129,7 +140,7 @@ $wifi_settings"
|
|||
if [ "$successful" -eq 0 ]; then
|
||||
echo -e "\033[0;31mNo internet connection detected.\033[0m"
|
||||
else
|
||||
echo -e "Internet connection is \033[4m\033[0;32mup\033[0m.\n\nPinged $(echo "${targets[*]}" | sed 's/ /, /g').\nReceived $successful/$total responses."
|
||||
echo -e "Internet connection is \033[4m\033[0;34mup\033[0m.\n\nPinged $(echo "${targets[*]}" | sed 's/ /, /g').\nReceived $successful/$total responses."
|
||||
fi
|
||||
;;
|
||||
r) # Option -r (restart Wi-Fi)
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ title="Software Manager"
|
|||
package_dir="/usr/local/bin/packages"
|
||||
|
||||
install() {
|
||||
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
|
||||
dialog --no-collapse --title "Install $($package_dir/$1.sh -N)" --yesno "\nInstallation requires internet connectivity.\n\nProceed?" 10 40
|
||||
[ $? -eq 1 ] && return 1 #if cancel/no
|
||||
|
||||
echo "Installing $($package_dir/$1.sh -N)..."
|
||||
# Run the installation script, capturing the output and displaying it in real time
|
||||
output=$($package_dir/$1.sh -i)
|
||||
|
|
@ -23,10 +22,8 @@ install() {
|
|||
}
|
||||
|
||||
uninstall() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nUninstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
dialog --no-collapse --title "Uninstall $($package_dir/$1.sh -N)" --yesno "\nReinstallation will require internet connectivity.\n\nProceed?" 10 40
|
||||
[ $? -eq 1 ] && return 1 #if cancel/no
|
||||
echo "Uninstalling $($package_dir/$1.sh -N)..."
|
||||
output=$(eval "$package_dir/$1.sh -u 2>&1 | tee /dev/tty")
|
||||
install_status=$? # Capture the exit status of the eval command
|
||||
|
|
@ -41,9 +38,7 @@ uninstall() {
|
|||
|
||||
initialize() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that require user interaction and so can only be run from terminal.\n\nProceed?" 13 50
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
[ $? -eq 1 ] && return 1 #if cancel/no
|
||||
clear
|
||||
echo "Initializing $($package_dir/$1.sh -N)..."
|
||||
eval "$package_dir/$1.sh -a"
|
||||
|
|
@ -55,10 +50,8 @@ initialize() {
|
|||
}
|
||||
|
||||
upgrade() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nUpgrade $($package_dir/$1.sh -N)\n\nProceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
dialog --no-collapse --title "Upgrade $($package_dir/$1.sh -N)" --yesno "\nUpgrade requires internet connectivity.\n\nProceed?" 10 40
|
||||
[ $? -eq 1 ] && return 1 #if cancel/no
|
||||
echo "Upgrading $($package_dir/$1.sh -N)..."
|
||||
output=$(eval "$package_dir/$1.sh -g 2>&1 | tee /dev/tty")
|
||||
install_status=$? # Capture the exit status of the eval command
|
||||
|
|
@ -107,16 +100,10 @@ package_menu() {
|
|||
$(if $package_dir/$1.sh -O | grep -q 'S' && $package_dir/$1.sh -I; then echo "Get service status x"; fi) \
|
||||
" " "" \
|
||||
"Back to software manager" "" 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
|
||||
break
|
||||
fi
|
||||
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
# execute the actual commands
|
||||
case $choice in
|
||||
"Run software") eval "$package_dir/$1.sh -l" ;;
|
||||
"Run software") echo "Launching $($package_dir/$1.sh -N)..." && eval "$package_dir/$1.sh -l" ;;
|
||||
"Install") install $1 ;;
|
||||
"Uninstall") uninstall $1 ;;
|
||||
"Initialize") initialize $1 ;;
|
||||
|
|
@ -145,10 +132,7 @@ while true; do
|
|||
menu_entries+=(" " "") # add blank line and "Back to Main Menu" entry
|
||||
menu_entries+=("$index" "Back to main menu")
|
||||
software_option=$(dialog --no-collapse --cancel-label "Back" --default-item "$software_option" --menu "$title" $((9 + index)) 50 $((index + 1)) "${menu_entries[@]}" 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
|
||||
break
|
||||
fi
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
|
||||
case_block=" case \$software_option in"
|
||||
index=1
|
||||
|
|
@ -166,11 +150,4 @@ while true; do
|
|||
eval "$case_block" # Execute the generated case statement
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
# 4 "Mosquitto MQTT broker" \
|
||||
# 5 "GPS and Telemetry" \
|
||||
|
||||
# 4) mosquitto ;;
|
||||
# 5) gpsd ;;
|
||||
exit 0
|
||||
|
|
@ -64,24 +64,26 @@ cpu_info() {
|
|||
local cpu_speed="$(lscpu | grep "CPU min MHz" | awk '{print int($4)}')-$(lscpu | grep "CPU max MHz" | awk '{print int($4)}')mhz"
|
||||
local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)"
|
||||
|
||||
echo -e "Core: $core\n\
|
||||
Model: $cpu_model\n\
|
||||
Architecture: $cpu_architecture\n\
|
||||
Speed: $cpu_speed x $(nproc) cores\n\
|
||||
Temperature: $cpu_temp\n\
|
||||
Serial # $cpu_serial"
|
||||
echo -e "\
|
||||
Core:$core\n\
|
||||
Model:$cpu_model\n\
|
||||
Architecture:$cpu_architecture\n\
|
||||
Speed:$cpu_speed x $(nproc) cores\n\
|
||||
Temperature:$cpu_temp\n\
|
||||
Serial #:$cpu_serial"
|
||||
}
|
||||
|
||||
storage_info() {
|
||||
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 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 [ -d "$dir" ] && echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "$(for dir in /mnt/*/; do [ -d "$dir" ] && echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')" || echo "none" )"
|
||||
|
||||
echo -e "microSD size: $microsd_size\n\
|
||||
Memory: $memory\n\
|
||||
Swap: $swap\n\
|
||||
$mounted_drives"
|
||||
echo -e "\
|
||||
microSD size:$microsd_size\n\
|
||||
Memory:$memory\n\
|
||||
Swap:$swap\n\
|
||||
Mnted drives:$mounted_drives"
|
||||
}
|
||||
|
||||
os_info() {
|
||||
|
|
@ -92,21 +94,22 @@ os_info() {
|
|||
local kernel_active_modules="$(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)"
|
||||
local kernel_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 "Operating System: $os_version\n\
|
||||
Kernel version: $(uname -r)\n\
|
||||
Uptime: $system_uptime\n\
|
||||
Logging: $logging_enabled\n\
|
||||
Activity LED: $act_led\n\
|
||||
System time: $(date)\n\
|
||||
K modules active: $kernel_active_modules\n\
|
||||
K boot modules: $kernel_boot_modules"
|
||||
echo -e "\
|
||||
OS:$os_version\n\
|
||||
Kernel ver:$(uname -r)\n\
|
||||
Uptime:$system_uptime\n\
|
||||
Logging:$logging_enabled\n\
|
||||
Activity LED:$act_led\n\
|
||||
System time:$(date)\n\
|
||||
K mods active:$kernel_active_modules\n\
|
||||
K boot mods:$kernel_boot_modules"
|
||||
}
|
||||
|
||||
networking_info() {
|
||||
local wifi_status="$(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="$(femto-network-config.sh -e)"
|
||||
echo -e "$wifi_status\n\
|
||||
---
|
||||
|
||||
$eth_status"
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +122,7 @@ peripherals_info() {
|
|||
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")"
|
||||
local lora_radio="$(femto-meshtasticd-config.sh -k)"
|
||||
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 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"}')"
|
||||
# gather i2c addresses
|
||||
i2c_addresses="" # initialize empty string to collect populated addresses
|
||||
while IFS= read -r line; do # iterate over each row of output (captured at end of while loop)
|
||||
|
|
@ -136,16 +139,16 @@ peripherals_info() {
|
|||
done <<< "$(echo "$(sudo i2cdetect -y 3)")"
|
||||
[[ -z "$i2c_addresses" ]] && i2c_addresses="none detected" # if no addresses found, "none detected"
|
||||
|
||||
echo -e "LoRa radio: $lora_radio\n\
|
||||
echo -e "LoRa radio:$lora_radio\n\
|
||||
$usb_devices\n\
|
||||
i2c devices: $i2c_addresses\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"
|
||||
i2c devices:$i2c_addresses\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"
|
||||
}
|
||||
|
||||
all_system_info() {
|
||||
|
|
@ -154,7 +157,7 @@ all_system_info() {
|
|||
CPU:\n\
|
||||
$(cpu_info)\n\
|
||||
\n\
|
||||
OS:\n\
|
||||
Operating System:\n\
|
||||
$(os_info)\n\
|
||||
\n\
|
||||
Storage:\n\
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ EOF
|
|||
|
||||
name="Contact" # software name
|
||||
author="pdxlocations" # software author - OPTIONAL
|
||||
description="A Text-Based Console UI for Meshtastic Nodes.\nAfter install, run \`contact\` to launch." # software description - OPTIONAL (but strongly recommended!)
|
||||
description="A Text-Based Console UI for Meshtastic Nodes. Formerly called Curse Client.\nAfter install, run \`contact\` to launch." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://github.com/pdxlocations/contact/" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiuglNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiuglNADUOLCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
|
||||
launch="python /opt/contact/main.py --host" # command to launch software, if applicable
|
||||
service_name="" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
location="/opt/contact" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
|
|
|
|||
|
|
@ -49,16 +49,16 @@ EOF
|
|||
# Messages to the user (such as configuration instructions, explanatory error messages, etc) should be given as: `echo "user_message: text"`
|
||||
# Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed
|
||||
|
||||
name="name" # software name
|
||||
author="author" # software author - OPTIONAL
|
||||
description="description" # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="URL" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiuagedsrlNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="service_name" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't
|
||||
location="/opt/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="package name, other package name" # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
|
||||
name="name" # software name
|
||||
author="author" # software author - OPTIONAL
|
||||
description="description" # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="URL" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="hxiuagedsrlNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
|
||||
launch="/opt/package/run.sh" # command to launch software, if applicable
|
||||
service_name="service_name" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't
|
||||
location="/opt/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="package1, package2" # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
|
||||
|
||||
# install script
|
||||
install() {
|
||||
|
|
@ -103,7 +103,7 @@ check() {
|
|||
fi
|
||||
}
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
while getopts ":$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ EOF
|
|||
# Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed
|
||||
|
||||
|
||||
name="TC2-BBS" # software name
|
||||
name="TC²-BBS" # software name
|
||||
author="The Comms Channel" # software author - OPTIONAL
|
||||
description="The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://github.com/TheCommsChannel/TC2-BBS-mesh" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue