Merge pull request #113 from noon92/femto-config

Femto config
This commit is contained in:
noon92 2025-01-01 21:26:15 +02:00 • committed by GitHub
commit 44d5944acd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 235 additions and 67 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

@ -0,0 +1,83 @@
#!/bin/bash
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,13 +35,13 @@ fi
# X X N X X\n\
# - + D - +"
luckfox="
luckfox="\
───────────────── \n\
VBUS 5V ●│● │ USB-C │ ●│● 1V8 OUT \n\
GND ●│● │ │ ●│● GND \n\
3V3 IN/OUT ●│● ─────── ●│● 145 (1.8V) \n\
UART-TX2 DEBUG, 42 ●│● ●│● 144 (1.8V) \n\
UART-RX2 DEBUG, 43 ●│● [BTN] ●│● 4 \n\
UART2-TX DEBUG, 42 ●│● ●│● 144 (1.8V) \n\
UART2-RX DEBUG, 43 ●│● [BTN] ●│● 4 \n\
CS0, 48 ●│● ●│● 55, IRQ \n\
CLK, 49 ●│● ●│● 54 BUSY \n\
MOSI, 50 ●│● ●│● 59, I2C SCL \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,8 +90,43 @@ 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 "
femtofox_zero="coming soon"
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="\
_____ _____ \n\
│() \ / ()│ \n\
│ \ / │ \n\
│ ───────── │ \n\
│ ───────────────── │ \n\
│ ●│● USB-C ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● LUCKFOX ●│● │ \n\
│ ●│● PICO MINI ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● FOXHOLE ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● ●│● │ \n\
│ ────●─●─●─●─●──── │ \n\
│─── ───────────── ───│ \n\
GND │ ● │ │ HT-RA62 │ │ ● │ GND \n\
3V3 │ ● │ │ _______ │ │ ● │ 3V3 \n\
UART4-RX │ ● │ │ │ │ │ │ ● │ I2C SDA \n\
UART4-TX │ ● │ │ │ WIO │ │ │ ● │ I2C SCL \n\
│─── │ │SX 1262│ │ ───│ \n\
│ │ │_______│ │ ● │ UNUSED \n\
│ ───────────── ● │ GND \n\
│() ETH ()│ \n\
────────●─●─●─●─●──────── \n\
R R G T T \n\
X X N X X \n\
- + D - + \n"
femtofox_tiny="coming soon"

View file

@ -1,20 +0,0 @@
#!/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"

View file

@ -0,0 +1 @@
femto-license.sh

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.