Refined femto-config

This commit is contained in:
nagumii 2025-01-03 00:03:27 +02:00
parent 90087fb55b
commit dc9bc7fb6f
12 changed files with 224 additions and 104 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

View file

@ -23,7 +23,7 @@ echo 34 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio34/direction
#(sleep 5 && cpufreq-set -u 408000 && echo "Boot complete, setting CPU frequency to 408mhz.") &
# run USB automount and config tool
/usr/local/bin/usbconfig.sh
/usr/local/bin/femto-usb-config-tool.sh
# boot complete
(

View file

@ -0,0 +1 @@
127.0.0.1 femtofox.local femtofox localhost

View file

@ -4,39 +4,7 @@
[ -r /etc/lsb-release ] && . /etc/lsb-release
#printf "\n"
echo "\e[92m
-+*#%%%%%%%%##*=:
.*%@*: .=%@#=
:%@*. =%@+
+%+ . -##:
.*@-:*#*= =#%@@- .*%-
=@- -@@@@@@@* -%@@@@@@@+ %#
%* -@%%@@@@@@@%: #@@@@@@#. #%. =%:
-@= @%: :*@@@@@@#===+*@@@@@@+ :@:+@#= :%+
-%: +@* :%@@@@@@@@@@@@%- .#-+@@@@%- .@+
.%= #@- -%@@@@@@@@@@@@@@@. +==@@@@@@%: @=
** #% .%@@@@@@@@@@@@@@@@@@%- ==+@@@@@@@@* -%:
:%: #- -+*#@@@@@@@@@@@@@%+. --#@@@@@@@@@%.+#
#* + .#@@@@@@@@@: :@@@@@@@@@@@#=%:
@+ ++. :%@@@@@* =@@@@@@@@@@@@###
@= .@@+ .#@@@= -@@@@@@@@@@@@**
@= +@%: =%@@%*: .@@* =%@@@%- @@@@@@@@@@@@*
%+ #@- .*@@@@% =% .%@@@%= +@@@@@@@@@@@@%
** . *#. :*%@@% + @@@%+. +@@@@@@@@@@@@@%
:* -* =#. .*@= %@= :#@@@@@@@@@@@@@@%
= %%= **. :- * -#@@@@@@@@@@@@@@@@*
@@%- +%- =@@@# :# +@@@@@@@@@@@@@@@@@@@-
.%@@@*. =*+-. -@@@@@@* .+@@@@@@@@@@@@@@@@@@@@@*
+@@@@@%+-. .-==--+%@@@@@@@@@@@@@@@@@@@@@@@#
. -%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
%= -#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
-%%%#=:.. ..-+#@@@@@@@@@@@@@@@@@@@@@@@@*
:#**%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%=
-*+.-#@@@@@@@@@@@@@@@@@@@@@@@@@@@*.
*#- :-=++==---=%@@@@@@#-
:+**+++*#%@%%%#*+-
\033[0m"
echo "\e[92m$(cat /usr/share/doc/femtofox/logo)\033[0m"
if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
# Fall back to using the very slow lsb_release utility

View file

@ -6,7 +6,7 @@ export LANG=C.UTF-8
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
echo "Try \`sudo femtofox-config\`."
echo "Try \`sudo femto-config\`."
exit 1
fi
@ -16,6 +16,24 @@ pause() {
read -n 1 -s -r
}
wifi_config() {
local wifi_ssid=""
local wifi_psk=""
local wifi_country=""
wifi_ssid=$(dialog --title "$title2" --cancel-label "Skip" --inputbox "Enter Wi-Fi SSID:" 8 40 3>&1 1>&2 2>&3)
wifi_psk=$(dialog --title "$title2" --cancel-label "Skip" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3)
wifi_country=$(dialog --title "$title2" --cancel-label "Skip" --inputbox "Enter Country Code (e.g., US, DE) - optional:" 9 40 3>&1 1>&2 2>&3)
cmd="femto-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\""
[ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\""
cmd="$cmd -r"
if [ -z "$wifi_ssid" ]; then
dialog --title "$title2" --msgbox "\nSSID is required." 8 40
return
fi
eval $cmd
dialog --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: $wifi_psk\nCountry: $wifi_country\nMeshtastic wifi setting set to ON" 9 40
}
# Function to handle Wi-Fi settings
networking_settings() {
local title="Networking"
@ -28,8 +46,9 @@ networking_settings() {
2 "Change wifi settings" \
3 "Restart wifi" \
4 "View ethernet settings" \
5 "Test internet connection" \
6 "Back to Main Menu" 3>&1 1>&2 2>&3)
5 "Set hostname" \
6 "Test internet connection" \
7 "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
@ -42,21 +61,7 @@ networking_settings() {
dialog --msgbox "$(femto-network-config.sh -w)" 0 0
;;
2)
local wifi_ssid=""
local wifi_psk=""
local wifi_country=""
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-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\""
[ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\""
cmd="$cmd -r"
if [ -z "$wifi_ssid" ]; then
dialog --title "$title2" --msgbox "\nSSID is required." 8 40
return
fi
eval $cmd
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
wifi_config
;;
3)
dialog --title "$title2" --yesno "Wifi and Ethernet will be restarted.\nMeshtastic wifi setting will be set to ON." 7 50
@ -68,11 +73,18 @@ networking_settings() {
echo "Getting ethernet configuration..."
dialog --title "Ethernet (eth0) settings" --msgbox "$(femto-network-config.sh -e)" 0 0
;;
5)
5) # set hostname)
new_hostname=$(dialog --title "$title" --cancel-label "Skip" --inputbox "Enter new hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then #unless cancel/no
femto-network-config.sh -n "$new_hostname"
dialog --title "$title" --msgbox "Femtofox is now reachable at\n$new_hostname.local" 8 40
fi
;;
6)
echo "Testing internet connection..."
dialog --title "Ethernet (eth0) settings" --msgbox "$(femto-network-config.sh -t)" 8 40
;;
6)
7)
return
;;
esac
@ -125,10 +137,10 @@ misc_settings() {
fi
case $option in
1)
1) # set timezone)
femto-set-timezone.sh
;;
2) # the contents of this should probably moved to a script
2) # the contents of this should probably moved to a script)
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\
@ -191,8 +203,8 @@ Rerunning the script will not cause any issues if these things are already in pl
set_lora_radio() {
while true; do
local option=""
option=$(dialog --menu "Misc" 0 0 10 \
1 "ebyte-e22-900m30s" \
option=$(dialog --cancel-label "Skip" --menu "Select your installed Meshtastic LoRa radio." 0 0 10 \
1 "ebyte-e22-900m30s (Femtofox Pro)" \
2 "ebyte-e22-900m22s" \
3 "ebyte-e80-900m22s" \
4 "heltec-ht-ra62" \
@ -203,7 +215,7 @@ set_lora_radio() {
9 "sx1262_xtal" \
10 "lr1121_tcxo" \
11 "none (simulated radio)" \
12 "Back to Meshtasticd Settings" 3>&1 1>&2 2>&3)
12 "Skip radio selection" 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
@ -250,7 +262,7 @@ set_lora_radio() {
;;
esac
if [ -n "$radio" ]; then #if a radio was selected
femto-meshtasticd-config.sh -l "$radio" -s # set the radio, then restart.
femto-meshtasticd-config.sh -l "$radio" -s # set the radio, then restart meshtasticd
return
fi
done
@ -289,7 +301,7 @@ meshtasticd_settings() {
pause
;;
2)
newurl=$(dialog --title "Meshtastic URL" --inputbox "New Meshtasticd URL (SHIFT+INS to paste):" 8 50 3>&1 1>&2 2>&3)
newurl=$(dialog --title "Meshtastic URL" --cancel-label "Skip" --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
@ -309,7 +321,7 @@ meshtasticd_settings() {
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)
key=$(dialog --title "Meshtastic Admin Key" --cancel-label "Skip" --inputbox "Meshtastic admin key - up to 3, more will be ignored.\n\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
@ -424,15 +436,32 @@ help_menu() {
done
}
# Parse options
while getopts ":lw" opt; do
case ${opt} in
l) # Option -l (set lora radio)
set_lora_radio
;;
w) # Option -w (wifi config)
wifi_config
;;
esac
done
if [ -n "$1" ]; then
exit
fi
# Main menu
while true; do
choice=$(dialog --title "$(date)" --menu "Femtofox Config" 15 40 5 \
1 "Networking" \
2 "Meshtasticd" \
3 "Misc" \
4 "Software" \
5 "Help" \
6 "Exit" 3>&1 1>&2 2>&3)
1 "Settings wizard" \
2 "Networking" \
3 "Meshtasticd" \
4 "Misc" \
5 "Software" \
6 "Help" \
7 "Exit" 3>&1 1>&2 2>&3)
exit_status=$? # This line checks the exit status of the dialog command
@ -441,13 +470,13 @@ while true; do
fi
case $choice in
1) networking_settings ;;
2) meshtasticd_settings ;;
3) misc_settings ;;
4) software_settings ;;
5) help_menu ;;
6) break ;;
1) femto-install-wizard.sh ;;
2) networking_settings ;;
3) meshtasticd_settings ;;
4) misc_settings ;;
5) software_settings ;;
6) help_menu ;;
7) break ;;
*) dialog --msgbox "Invalid choice, please try again." 8 40 ;;
esac
done
done

View file

@ -0,0 +1,85 @@
#!/bin/bash
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 femto-install-wizard\`."
exit 1
fi
# pause
pause() {
echo "Press any key to continue..."
read -n 1 -s -r
}
title="Install Wizard"
wizard() {
femto-set-timezone.sh
new_hostname=$(dialog --title "$title" --cancel-label "Skip" --inputbox "Enter hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then #unless cancel/no
femto-network-config.sh -n "$new_hostname"
dialog --title "$title" --msgbox "\nFemtofox is now reachable at\n$new_hostname.local" 8 40
fi
dialog --title "$title" --cancel-label "Skip" --yesno "\nConfigure wifi settings?" 8 40
if [ $? -eq 0 ]; then #unless cancel/no
femto-config -w
fi
dialog --title "$title" --cancel-label "Skip" --yesno "\nConfigure Meshtastic?" 8 40
if [ $? -eq 0 ]; then #unless cancel/no
newurl=$(dialog --title "Meshtastic URL" --cancel-label "Skip" --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
femto-config -l
key=$(dialog --title "$title" --cancel-label "Skip" --inputbox "Enter Meshtastic admin key (optional) - 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
while true; do
choice=$(dialog --title "$title" --cancel-label "Skip" --menu "Enable/disable Meshtastic Legacy admin channel?" 11 40 5 \
1 "Enable" \
2 "Disable (default)" \
3 "Skip" 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) femto-meshtasticd-config.sh -o "true" ;;
2) femto-meshtasticd-config.sh -o "false" ;;
3) return ;;
*) dialog --msgbox "Invalid choice, please try again." 8 40 ;;
esac
done
fi
dialog --title "$title" --msgbox "\nSetup wizard complete!" 8 40
}
dialog --title "$title" --yesno "\
The install wizard will allow you to configure all the settings necessary to run your Femtofox.\n\
\n\
Running this wizard will overwrite some current settings.\n\
Proceed?" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
wizard
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. Try \`sudo femto-wifi-config\`."
echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`."
exit 1
fi

View file

@ -14,6 +14,7 @@ Options are:
-r Restart wifi
-e Get ethernet settings
-w Get wifi settings
-n "HOSTNAME" Change hostname
-t Test internet connection
To set wifi settings, use -r as last argument to trigger reset after wpa_supplicant.conf is modified.
@ -34,7 +35,7 @@ if [ $# -eq 0 ]; then
fi
# Parse options
while getopts ":hs:p:c:ewtr" opt; do
while getopts ":hs:p:c:ewn:tr" opt; do
case ${opt} in
h) # Option -h (help)
echo -e "$help"
@ -55,9 +56,11 @@ while getopts ":hs:p:c:ewtr" opt; do
updated_wifi="true"
;;
e) # Option -e (ethernet settings)
echo "IPv4 Address: $(ifconfig eth0 | grep 'inet ' | awk '{print $2}')\n
echo "Hostname: $(hostname).local\n\
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}')"
MAC Address: $(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\
"
;;
w) # Option -w (wifi settings)
wifi_country=$(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)
@ -78,7 +81,8 @@ Connected to: $(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{p
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
Hostname: $(hostname).local\n\
For more details, enter \`iwconfig\`."
;;
t) # Option -t (test internet connection)
# Define ping targets and initialize counter
@ -102,6 +106,11 @@ For more details, enter \`iwconfig\`." 0 0
r) # Option -r (restart wifi)
updated_wifi="true"
;;
n) # Option -n (set hostname)
sed -i "s/$(hostname)/$OPTARG/g" /etc/hosts
hostnamectl set-hostname "$OPTARG"
systemctl restart avahi-daemon
;;
\?) # Invalid option
echo "Invalid option: -$OPTARG"
echo -e "$help"

View file

@ -36,25 +36,25 @@ fi
# - + D - +"
luckfox="\
───────────────── \n\
VBUS 5V ●│● │ USB-C │ ●│● 1V8 OUT \n\
GND ●│● │ │ ●│● GND \n\
3V3 IN/OUT ●│● ─────── ●│● 145 (1.8V) \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\
MISO, 51 ●│● ●│● 58, I2C SDA \n\
UART4-RX, 52 ●│● ●│● 57, UART3-RX, NRST \n\
UART4-TX, 53 ●│● ETH ●│● 56, UART3-TX RXEN \n\
──●──●──●──●──●── \n\
R R G T T \n\
X X N X X \n\
- + D - + \n\
GPIO BANK 0: 4 \n\
GPIO BANK 1: 42 43 48 49 50 51 52 53 54 55 56 57 58 59 \n\
GPIO BANK 4: 144 145 "
───────────────── \n\
VBUS 5V ●│● │ USB-C │ ●│● 1V8 OUT \n\
GND ●│● │ │ ●│● GND \n\
3V3 IN/OUT ●│● ─────── ●│● 145 (1.8V) \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\
MISO, 51 ●│● ●│● 58, I2C SDA \n\
UART4-RX, 52 ●│● ●│● 57, NRST, UART3-RX \n\
UART4-TX, 53 ●│● ETH ●│● 56, RXEN, UART3-TX \n\
──●──●──●──●──●── \n\
R R G T T \n\
X X N X X \n\
- + D - + \n\
GPIO BANK 0 (3.3v): 4 \n\
GPIO BANK 1 (3.3v): 42 43 48 49 50 51 52 53 54 55 56 57 58 59\n\
GPIO BANK 4 (1.8v): 144 145 "
femtofox="\
──────────────────────────────────────────────────────────────── \n\

View file

@ -48,7 +48,7 @@ done
# Fetch available time zones
timezones=$(timedatectl list-timezones)
if [[ -z "$timezones" ]]; then
dialog --msgbox "Failed to retrieve time zones. Ensure 'timedatectl' is installed and functional." 8 50
dialog --msgbox "\nFailed to retrieve time zones. Ensure 'timedatectl' is installed and functional." 8 40
return
fi
@ -61,11 +61,9 @@ done <<< "$timezones"
options_str=$(printf '%s\n' "${options[@]}")
# Show timezone selection menu
selected_timezone=$(dialog --title "Select Time Zone" --menu "Choose a time zone:" 20 60 10 $(printf "%s " "${options[@]}") 3>&1 1>&2 2>&3)
selected_timezone=$(dialog --title "Select Time Zone" --cancel-label "Skip" --menu "Choose a time zone:" 20 60 10 $(printf "%s " "${options[@]}") 3>&1 1>&2 2>&3)
exit_status=$?
if [[ $exit_status -eq 0 && -n "$selected_timezone" ]]; then
# Set the selected time zone
set_timezone $selected_timezone
else
dialog --msgbox "No time zone selected. Returning to menu." 8 40
fi

View file

@ -0,0 +1,30 @@
-+*#%%%%%%%%##*=:
.*%@*: .=%@#=
:%@*. =%@+
+%+ . -##:
.*@-:*#*= =#%@@- .*%-
=@- -@@@@@@@* -%@@@@@@@+ %#
%* -@%%@@@@@@@%: #@@@@@@#. #%. =%:
-@= @%: :*@@@@@@#===+*@@@@@@+ :@:+@#= :%+
-%: +@* :%@@@@@@@@@@@@%- .#-+@@@@%- .@+
.%= #@- -%@@@@@@@@@@@@@@@. +==@@@@@@%: @=
** #% .%@@@@@@@@@@@@@@@@@@%- ==+@@@@@@@@* -%:
:%: #- -+*#@@@@@@@@@@@@@%+. --#@@@@@@@@@%.+#
#* + .#@@@@@@@@@: :@@@@@@@@@@@#=%:
@+ ++. :%@@@@@* =@@@@@@@@@@@@###
@= .@@+ .#@@@= -@@@@@@@@@@@@**
@= +@%: =%@@%*: .@@* =%@@@%- @@@@@@@@@@@@*
%+ #@- .*@@@@% =% .%@@@%= +@@@@@@@@@@@@%
** . *#. :*%@@% + @@@%+. +@@@@@@@@@@@@@%
:* -* =#. .*@= %@= :#@@@@@@@@@@@@@@%
= %%= **. :- * -#@@@@@@@@@@@@@@@@*
@@%- +%- =@@@# :# +@@@@@@@@@@@@@@@@@@@-
.%@@@*. =*+-. -@@@@@@* .+@@@@@@@@@@@@@@@@@@@@@*
+@@@@@%+-. .-==--+%@@@@@@@@@@@@@@@@@@@@@@@#
. -%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
%= -#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
-%%%#=:.. ..-+#@@@@@@@@@@@@@@@@@@@@@@@@*
:#**%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%=
-*+.-#@@@@@@@@@@@@@@@@@@@@@@@@@@@*.
*#- :-=++==---=%@@@@@@#-
:+**+++*#%@%%%#*+-