femto-config MVP

This commit is contained in:
nagumii 2025-01-01 21:25:57 +02:00
parent eac22e9d0c
commit 3f250a3ed2
8 changed files with 198 additions and 428 deletions

View file

@ -47,8 +47,8 @@ fi
foxbuntu_version=$(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)
spaces=$((11 - ${#foxbuntu_version}))
printf " For settings, run \`sudo femto-config\`\n"
printf " Made for Femtofox https://www.femtofox.com\n"
printf " Foxbuntu v$foxbuntu_version%*s%s(%s)\n" $spaces "" "$DISTRIB_DESCRIPTION" "$(uname -r)"
printf " For Femtofox, Foxbuntu and Meshtastic licenses, run \`license\`\n\n"
printf " Foxbuntu v$foxbuntu_version%*s%s(%s)\n\n" $spaces "" "$DISTRIB_DESCRIPTION" "$(uname -r)"
printf "IP address: $(hostname -I | sed 's/ / /g') 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"

View file

@ -17,16 +17,19 @@ pause() {
}
# Function to handle Wi-Fi settings
wifi_settings() {
local title="Wifi settings"
networking_settings() {
local title="Networking"
local title2="Wifi Settings"
wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf"
while true; do
local option=""
option=$(dialog --menu "Wifi settings" 15 40 4 \
option=$(dialog --menu "$title" 15 40 4 \
1 "View wifi settings" \
2 "Change wifi settings" \
3 "Restart wifi" \
4 "Back to Main Menu" 3>&1 1>&2 2>&3)
4 "Ethernet settings" \
5 "Test internet connection" \
6 "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
@ -43,7 +46,7 @@ wifi_settings() {
else
mesh_wifi_status="disabled"
fi
dialog --title "$title" --msgbox "\
dialog --title "$title2" --msgbox "\
SSID: $wifi_ssid\n\
Password: $wifi_psk\n\
Country: $wifi_country\n\
@ -51,6 +54,7 @@ Meshtastic wifi: $mesh_wifi_status\n\
\n\
Connected to: $(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}')\n\
Signal Strength: $(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\
MAC address: $(ifconfig wlan0 | grep ether | awk '{print $2}')\n\
Current IP: $(hostname -I | awk '{print $1}')\n\
For more details, enter \`iwconfig\`.
" 0 0
@ -59,24 +63,54 @@ For more details, enter \`iwconfig\`.
local wifi_ssid=""
local wifi_psk=""
local wifi_country=""
wifi_ssid=$(dialog --title "$title" --inputbox "Enter Wi-Fi SSID:" 8 40 3>&1 1>&2 2>&3)
wifi_psk=$(dialog --title "$title" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3)
wifi_country=$(dialog --title "$title" --inputbox "Enter Country Code (e.g., US, DE) - optional:" 9 40 3>&1 1>&2 2>&3)
wifi_ssid=$(dialog --title "$title2" --inputbox "Enter Wi-Fi SSID:" 8 40 3>&1 1>&2 2>&3)
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 (e.g., US, DE) - optional:" 9 40 3>&1 1>&2 2>&3)
cmd="femto-wifi-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\""
[ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\""
echo $cmd
if [ -z "$wifi_ssid" ]; then
dialog --title "$title" --msgbox "\nSSID is required." 8 40
dialog --title "$title2" --msgbox "\nSSID is required." 8 40
return
fi
eval $cmd
dialog --title "$title" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: $wifi_psk\nCountry: $wifi_country\nMeshtastic wifi setting set to ON" 10 40
dialog --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: $wifi_psk\nCountry: $wifi_country\nMeshtastic wifi setting set to ON" 10 40
;;
3)
dialog --title "Wifi restart" --msgbox "Wifi will be restarted.\nMeshtastic wifi setting will be set to ON." 7 50
femto-wifi-config.sh -r
dialog --title "$title2" --yesno "Wifi and Ethernet will be restarted.\nMeshtastic wifi setting will be set to ON." 7 50
if [ $? -eq 0 ]; then #unless cancel/no
femto-wifi-config.sh -r
fi
;;
4)
dialog --title "Ethernet (eth0) settings" --msgbox "\
IPv4 Address: $(ifconfig eth0 | grep 'inet ' | awk '{print $2}')\n\
IPv6 Address: $(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')\n\
MAC Address: $(ifconfig eth0 | grep 'ether ' | awk '{print $2}')" 0 0
;;
5)
echo "Testing internet connection..."
# Define ping targets and initialize counter
targets=("1.1.1.1" "8.8.8.8")
successful=0
count=0
total=0
# Ping each target 5 times and count successful pings
for target in "${targets[@]}"; do
count=$(ping -c 5 -W 1 "$target" | grep -c 'bytes from') # Count lines with successful pings
successful=$((successful + count))
((total+=5))
done
# Use dialog to display message based on successful pings count
if [ "$successful" -eq 0 ]; then
dialog --msgbox "No internet connection detected." 6 50
else
dialog --msgbox "Internet connection is up.\n\nPinged $(echo "${targets[*]}" | sed 's/ /, /g').\nReceived $successful/$total responses." 8 40
fi
;;
6)
return
;;
esac
@ -92,7 +126,7 @@ femto_pinouts() {
2 "Femtofox Zero" \
3 "Femtofox Tiny" \
4 "Luckfox Pico Mini" \
5 "Back to Misc Settings" 3>&1 1>&2 2>&3)
5 "Back to Help Menu" 3>&1 1>&2 2>&3)
exit_status=$? # This line checks the exit status of the dialog command
@ -101,8 +135,8 @@ femto_pinouts() {
fi
case $option in
1) dialog --title "Femtofox" --msgbox "$(femto-pinout.sh -f)" 38 70 ;;
2) dialog --title "Femtofox Zero" --msgbox "$(femto-pinout.sh -z)" 38 70 ;;
1) dialog --title "Femtofox" --msgbox "$(femto-pinout.sh -f)" 41 70 ;;
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 63 ;;
5) return ;;
@ -120,9 +154,8 @@ misc_settings() {
1 "Set system timezone" \
2 "Ham radio support" \
3 "Re-run first-boot script" \
4 "Display pinout" \
5 "Run OEM luckfox-config" \
6 "Back to Main Menu" 3>&1 1>&2 2>&3)
4 "Run OEM luckfox-config" \
5 "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
@ -183,12 +216,9 @@ Rerunning the script will not cause any issues if these things are already in pl
fi
;;
4)
femto_pinouts
;;
5)
luckfox-config
;;
6)
5)
return
;;
esac
@ -211,7 +241,7 @@ set_lora_radio() {
9 "sx1262_xtal" \
10 "lr1121_tcxo" \
11 "none (simulated radio)" \
12 "Back to Main Menu" 3>&1 1>&2 2>&3)
12 "Back to Meshtasticd Settings" 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
@ -363,11 +393,61 @@ meshtasticd_settings() {
done
}
#Help menu
help_menu() {
while true; do
local title="Help / About"
local option=""
option=$(dialog --menu "$title" 0 0 6 \
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 -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
break
fi
case $option in
1)
dialog --msgbox "$(femto-license.sh -a)" 0 0
;;
2)
femto_pinouts
;;
3)
dialog --msgbox "$(femto-license.sh -f)" 28 60
;;
4)
femto-license.sh -F
echo -e "\nPress any key to continue...\n"
read -n 1 -s -r
;;
5)
dialog --msgbox "$(femto-license.sh -m)" 0 0
;;
6)
dialog --msgbox "$(femto-license.sh -l)" 0 0
;;
7)
dialog --msgbox "$(femto-license.sh -u)" 0 0
;;
8)
return
;;
esac
done
}
# Main menu
while true; do
choice=$(dialog --title "$(date)" --menu "Femtofox Config" 15 40 5 \
1 "Wi-Fi" \
1 "Networking" \
2 "Meshtasticd" \
3 "Misc" \
4 "Software" \
@ -381,11 +461,11 @@ while true; do
fi
case $choice in
1) wifi_settings ;;
1) networking_settings ;;
2) meshtasticd_settings ;;
3) misc_settings ;;
4) software_settings ;;
5) femto_help ;;
5) help_menu ;;
6) break ;;
*) dialog --msgbox "Invalid choice, please try again." 8 40 ;;
esac

View file

@ -1,20 +1,83 @@
#!/bin/bash
echo
echo
echo
cat /usr/share/doc/femtofox/foxbuntu/short_license
echo
echo
echo "Press any key to continue..."
read -n 1 -s -r
cat /usr/share/doc/femtofox/foxbuntu/long_license
echo
echo
printf "Press any key to continue..."
read -n 1 -s -r
echo
echo
echo
printf " Meshtastic is a registered trademark of Meshtastic LLC.\n"
printf " Meshtastic software components are released under various licenses,\n"
printf " see GitHub for details. No warranty is provided - use at your own risk.\n"
help=$(cat <<EOF
Options are:
-h This message
-a About Femtofox
-f Femtofox short-form license
-F Femtofox long-form license
-m Meshtastic licensing
-l Luckfox license
-u Ubuntu licenses
EOF
)
anykey="echo -e \"\nPress any key to continue...\n\" && read -n 1 -s -r"
femtofox_short_license="\
Femtofox and Foxbuntu are published under CC BY-NC-ND - noncommercial.\n\
For more information, visit us at www.femtofox.com.\n\
\n\
Summary:\n\
You can share Femtofox and Foxbuntu or make modifications, but can't sell it except by arrangement (license) with us.\n\
In this context, Foxbuntu refers to the modifications to Ubuntu made as part of the Femtofox project.\n\
\n\
Boilerplate:\n\
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.\n\
You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.\n\
NonCommercial — You may not use the material for commercial purposes.\n\
NoDerivatives — If you remix, transform, or build upon the material, you may not distribute the modified material (for commercial purposes).\n\
\n\
Contact us to license Femtofox."
meshtastic_license="\
Meshtastic is a registered trademark of Meshtastic LLC. Meshtastic software components are released under various licenses, see GitHub for details. No warranty is provided - use at your own risk."
luckfox_license="Luckfox and Luckfox Pico Mini are property of Luckfox Technology. Femtofox does not represent Luckfox Technology in any way, shape or form. Visit their website at https://www.luckfox.com/."
ubuntu_license="Ubuntu is a trademark of Canonical. Femtofox does not represent Ubuntu or Canonical in any way, shape or form. Find Ubuntu's license information on their site, https://ubuntu.com/legal. Licenses are also available in \`/usr/share/common-licenses\`."
# Parse options
while getopts ":hafFmlu" opt; do
case ${opt} in
h) # Option -h (help)
echo -e "$help"
;;
a) # Option -a (about)
echo "The Luckfox Pico Mini is a compact and power efficient Linux capable board, capable of running Ubuntu. Femtofox is an expansion of the Luckfox's capabilities, combining a customized Ubuntu image with a custom PCB, integrating it with a LoRa radio to create a power efficient, cheap and small Meshtastic Linux node."
;;
f) # Option -f (Femtofox short-form license)
echo "$femtofox_short_license"
;;
F) # Option -F (Femtofox long-form license)
echo "$(cat /usr/share/doc/femtofox/long_license)"
;;
m) # Option -m (Meshtastic licensing)
echo "$meshtastic_license"
;;
l) # Option -l (Luckfox license)
echo "$luckfox_license"
;;
u) # Option -u (Ubuntu licenses)
echo "$ubuntu_license"
;;
\?) # Invalid option
echo "Invalid option: -$OPTARG"
echo -e "$help"
exit 1
;;
esac
done
# if no arguments, show all licenses
if [ $# -eq 0 ]; then
echo "$femtofox_short_license"
eval $anykey
echo "$(cat /usr/share/doc/femtofox/long_license)"
eval $anykey
echo "$meshtastic_license"
eval $anykey
echo "$luckfox_license"
eval $anykey
eval "$ubuntu_license"
eval $anykey
fi

View file

@ -35,7 +35,7 @@ fi
# X X N X X\n\
# - + D - +"
luckfox="
luckfox="\
───────────────── \n\
VBUS 5V ●│● │ USB-C │ ●│● 1V8 OUT \n\
GND ●│● │ │ ●│● GND \n\
@ -58,7 +58,7 @@ GPIO BANK 4: 144 145 "
femtofox="\
──────────────────────────────────────────────────────────────── \n\
│( ):FUSE ●│● USB-C ●│● PWR-IN |+ -| 3.3-5V ( )│\n\
│()⦂︎KILL ●│● USB-C ●│● PWR-IN |+ -| 3.3-5V ()│\n\
│─────── ●│● ●│● ─── │\n\
│ USB-C │ ●│● ●│● ───────────────────────────── │\n\
│ POWER │ ●│● LUCKFOX ●│● │ _____________ │ │\n\
@ -69,7 +69,7 @@ femtofox="\
│ ● │TX4 ●│● ●│● │ | │ │ │ │\n\
│ ● │RX4 ●│● ●│● │ 9 │ │ │ │\n\
│─── ●│● ●│● │ 0 │_____________│ │ │\n\
│( ) ───●─●─●─●─●─── │ 0 ___________ │ │\n\
│() ───●─●─●─●─●─── │ 0 ___________ │ │\n\
│────────────────── │ M │ │ │ │\n\
│ ● RX- │ I2C GROVE │ 3 │ SEEED │ │ │\n\
│ ● RX+ │ ─────── │ 0 │WIO SX1262│ │ │\n\
@ -78,7 +78,7 @@ femtofox="\
│ ● TX+ │ │● ● ● ●│ │ │ │\n\
│────────────────── ─────── ───────────────────────────── │\n\
│ ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● │\n\
│( )● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●( )│\n\
│() ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ()│\n\
──────────────────────────────────────────────────────────────── \n\
\n\
R M M \n\
@ -90,7 +90,10 @@ femtofox="\
C B I G G G G R R T G 5 5 \n\
S U R N N N N S X X N V V \n\
0 S Q D D D D T 4 4 D \n\
Y "
Y \n\
ꙩ︎ pins available on Femtofox Pro. Unused on Femtofox basic model. \n\
KILL pins available on Femtofox Pro only. Add power switch or \n\
thermal fuse/cutoff here and remove resistor. "
femtofox_zero="\

View file

@ -1,365 +0,0 @@
#!/bin/bash
# prevents weirdness over tty
export NCURSES_NO_UTF8_ACS=1
export TERM=xterm-256color
export LANG=C.UTF-8
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
echo "Try \`sudo femtofox-config\`."
exit 1
fi
# pause
pause() {
echo "Press any key to continue..."
read -n 1 -s -r
}
# Function to handle Wi-Fi settings
wifi_settings() {
local title="Wifi settings"
wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf"
while true; do
local option=""
option=$(dialog --menu "Wifi settings" 15 40 4 \
1 "View wifi settings" \
2 "Change wifi settings" \
3 "Restart wifi" \
4 "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
break
fi
case $option in
1)
wifi_country=$(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)
wifi_ssid=$(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)
wifi_psk=$(grep -m 1 '^\s*psk=' "$wpa_supplicant_conf" | cut -d '"' -f 2)
if [ "$(cat /root/.portduino/default/prefs/config.proto | protoc --decode_raw | awk '/4 {/, /}/ {if ($1 == "1:") print $2}')" -eq 1 ]; then
mesh_wifi_status="enabled"
else
mesh_wifi_status="disabled"
fi
dialog --title "$title" --msgbox "\
SSID: $wifi_ssid\n\
Password: $wifi_psk\n\
Country: $wifi_country\n\
Meshtastic wifi: $mesh_wifi_status\n\
\n\
Connected to: $(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}')\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\
For more details, enter \`iwconfig\`.
" 0 0
;;
2)
local wifi_ssid=""
local wifi_psk=""
local wifi_country=""
wifi_ssid=$(dialog --title "$title" --inputbox "Enter Wi-Fi SSID:" 8 40 3>&1 1>&2 2>&3)
wifi_psk=$(dialog --title "$title" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3)
wifi_country=$(dialog --title "$title" --inputbox "Enter Country Code (e.g., US, DE) - optional:" 9 40 3>&1 1>&2 2>&3)
cmd="femto-wifi-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\""
[ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\""
echo $cmd
if [ -z "$wifi_ssid" ]; then
dialog --title "$title" --msgbox "\nSSID is required." 8 40
return
fi
eval $cmd
dialog --title "$title" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: $wifi_psk\nCountry: $wifi_country\nMeshtastic wifi setting set to ON" 10 40
;;
3)
dialog --title "Wifi restart" --msgbox "Wifi will be restarted.\nMeshtastic wifi setting will be set to ON." 7 50
femto-wifi-config.sh -r
;;
4)
return
;;
esac
done
}
# Function to handle misc settings
misc_settings() {
local title="Misc Settings"
while true; do
local option=""
option=$(dialog --menu "Misc Settings" 15 40 4 \
1 "Set system timezone" \
2 "Ham radio support" \
3 "Re-run first-boot script" \
4 "Display pinout" \
5 "Run OEM luckfox-config" \
6 "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
break
fi
case $option in
1)
femto-set-timezone.sh
;;
2)
dialog --title "$title" --msgbox "Amateur radio support can be added in kernel for:\n\n\
Amateur Radio AX.25 Level 2 protocol\n\
AX.25 DAMA Slave support\n\
Amateur Radio NET/ROM protocol\n\
Amateur Radio X.25 PLP (Rose)\n\
Serial port KISS driver\n\
Serial port 6PACK driver\n\
BPQ Ethernet driver\n\
BAYCOM ser12 fullduplex driver for AX.25\n\
BAYCOM ser12 halfduplex driver for AX.25\n\
YAM driver for AX.25\n\
AM/FM Radio receivers/transmitters\n\
Software defined radio (SDR)\n\
Maxim 2175 RF to Bits tuner\n\
Silicon Labs Si470x FM Radio Receiver support\n\
Silicon Labs Si470x FM Radio Receiver support with USB\n\
Silicon Labs Si470x FM Radio Receiver support with I2C\n\
Silicon Labs Si4713 FM Radio with RDS Transmitter support\n\
Silicon Labs Si4713 FM Radio Transmitter support with USB\n\
Silicon Labs Si4713 FM Radio Transmitter support with I2C\n\
Silicon Labs Si4713 FM Radio Transmitter support\n\
AverMedia MR 800 USB FM radio support\n\
D-Link/GemTek USB FM radio support\n\
Guillemot MAXI Radio FM 2000 radio\n\
Griffin radioSHARK USB radio receiver\n\
Griffin radioSHARK2 USB radio receiver\n\
Keene FM Transmitter USB support\n\
Thanko's Raremono AM/FM/SW radio support\n\
Masterkit MA901 USB FM radio support\n\
TEA5764 I2C FM radio support\n\
SAA7706H Car Radio DSP\n\
TEF6862 Car Radio Enhanced Selectivity Tuner\n\
Texas Instruments WL1273 I2C FM Radio\n\
Renesas Digital Radio Interface (DRIF)" 20 65
dialog --title "$title" --msgbox "To add support, kernel modules for all these will be copied to \`/lib/modules/5.10.160/\`,\
then \`depmod\` will be run. To remove support, those modules will be deleted.\n\nAfter installation, many redundant network interfaces will appear." 11 50
#add code to choose add or remove
cp /oem/usr/ko/ham/* /lib/modules/5.10.160/
depmod -a 5.10.160
;;
3)
dialog --title "$title" --yesno "Rerunning the first-boot script will add support for RTC (real time clock), \
set the eth0 MAC address and Meshtastic nodeID to a derivative of the CPU serial number and enable wifi in Meshtastic settings. \
Rerunning the script will not cause any issues if these things are already in place. Femtofox will reboot after execution.\n\nConfirm?" 12 60
if [ $? -eq 0 ]; then #unless cancel/no
runonce.sh
fi
;;
4)
dialog --title "$title" --msgbox "$(femto-pinout.sh -a | sed 's/|n/\\n/g')" 0 0
;;
5)
luckfox-config
;;
6)
return
;;
esac
done
}
#set lora radio
set_lora_radio() {
while true; do
local option=""
option=$(dialog --menu "Misc" 0 0 10 \
1 "ebyte-e22-900m30s" \
2 "ebyte-e22-900m22s" \
3 "ebyte-e80-900m22s" \
4 "heltec-ht-ra62" \
5 "seeed-wio-sx1262" \
6 "waveshare-sx126x-xxxm" \
7 "ai-thinker-ra-01sh" \
8 "sx1262_tcxo" \
9 "sx1262_xtal" \
10 "lr1121_tcxo" \
11 "none (simulated radio)" \
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 -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
break
fi
local radio=""
case $option in
1)
radio="sx1262_tcxo"
;;
2)
radio="sx1262_tcxo"
;;
3)
radio="sx1262_xtal"
;;
4)
radio="sx1262_tcxo"
;;
5)
radio="sx1262_tcxo"
;;
6)
radio="sx1262_xtal"
;;
7)
radio="sx1262_xtal"
;;
8)
radio="sx1262_tcxo"
;;
9)
radio="sx1262_xtal"
;;
10)
radio="lr1121_tcxo"
;;
11)
radio="none"
;;
12)
return
;;
esac
if [ -n "$radio" ]; then #if a radio was selected
femto-meshtasticd-config.sh -l "$radio"
return
fi
done
}
# Function to handle Meshtasticd settings
meshtasticd_settings() {
local title="Meshtasticd Settings"
while true; do
local option=""
option=$(dialog --menu "$title" 19 50 4 \
1 "Get current configuration URL & QR code" \
2 "Set new configuration URL" \
3 "Get current lora radio selection" \
4 "Set LoRa radio" \
5 "View current admin keys" \
6 "Set admin key" \
7 "Clear admin keys" \
8 "Enable legacy admin channel" \
9 "Disable legacy admin channel" \
10 "Upgrade Meshtasticd" \
11 "Uninstall Meshtasticd" \
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 -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
break
fi
case $option in
1) #Get current configuration URL & QR code)
femto-meshtasticd-config.sh -g
pause
;;
2)
newurl=$(dialog --title "Meshtastic URL" --inputbox "New Meshtasticd URL (SHIFT+INS to paste):" 8 50 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
if [ $? -eq 0 ]; then #unless cancel/no
femto-meshtasticd-config.sh -q "$newurl"
pause
fi
fi
;;
3)
dialog --title "LoRa radio" --msgbox "Currently configured LoRa radio: $(femto-meshtasticd-config.sh -k)" 6 40
;;
4)
set_lora_radio
;;
5)
echo "Getting admin keys..."
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
;;
6) #set admin key)
key=$(dialog --title "Meshtastic Admin Key" --inputbox "Meshtastic admin key - up to 3, more will be ignored.\n(SHIFT+INS to paste):" 8 50 3>&1 1>&2 2>&3)
if [ -n "$key" ]; then #if a URL was entered
femto-meshtasticd-config.sh -a "$key"
pause
fi
;;
7)
dialog --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
;;
8) #enable legacy)
dialog --title "$title" --yesno "Enable legacy admin channel?" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
femto-meshtasticd-config.sh -e
pause
fi
;;
9) #disable legacy)
dialog --title "$title" --yesno "Disable legacy admin channel?" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
femto-meshtasticd-config.sh -d
pause
fi
;;
10) #Upgrade meshtasticd)
dialog --title "$title" --yesno "Upgrade Meshtasticd?\nRequires internet connection." 0 0
if [ $? -eq 0 ]; then #unless cancel/no
femto-meshtasticd-config.sh -u
pause
fi
;;
11)
dialog --title "$title" --yesno "Uninstall Meshtasticd?" 0 0
if [ $? -eq 0 ]; then
femto-meshtasticd-config.sh -r
dialog --msgbox "Meshtasticd uninstalled. To purge all remnants, run \`sudo apt purge\`.\nAfter reinstallation but before first launch, run \`sudo runonce.sh\`." 8 40
fi
pause
;;
12)
return
;;
esac
done
}
# Main menu
while true; do
choice=$(dialog --title "$(date)" --menu "Femtofox Config" 15 40 5 \
1 "Wi-Fi" \
2 "Meshtasticd" \
3 "Misc" \
4 "Software" \
5 "Help" \
6 "Exit" 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
case $choice in
1) wifi_settings ;;
2) meshtasticd_settings ;;
3) misc_settings ;;
4) software_settings ;;
5) femto_help ;;
6) break ;;
*) dialog --msgbox "Invalid choice, please try again." 8 40 ;;
esac
done

View file

@ -265,7 +265,6 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then
fi
fi
log_message "USB config complete, unplug USB drive."
for _ in {1..10}; do #do our successful config boot code
blink "0.125" && sleep 0.125
done

View file

@ -1,10 +0,0 @@
Femtofox and Foxbuntu are published under CC BY-NC-ND - noncommercial.
For more information, visit us at https://www.femtofox.com
Summary:
Attribution — You must give appropriate credit , provide a link to the license, and indicate if changes were made.
You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
NonCommercial — You may not use the material for commercial purposes .
NoDerivatives — If you remix, transform, or build upon the material, you may not distribute the modified material.
Contact us to license Femtofox.