Fix small bugs in install wizard.

This commit is contained in:
nagumii 2025-01-03 14:20:23 +02:00
parent d47404db35
commit 7469af10e6
3 changed files with 33 additions and 32 deletions

View file

@ -27,24 +27,24 @@ wifi_config() {
[ -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
dialog --title "$title2" --msgbox "\nSSID is required to configure Wi-Fi." 8 40
return
fi
eval $cmd
dialog --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: $wifi_psk\nCountry: $wifi_country\nMeshtastic wifi setting set to ON" 9 40
dialog --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: $wifi_psk\nCountry: $wifi_country\nMeshtastic Wi-Fi setting set to ON" 9 40
}
# Function to handle Wi-Fi settings
networking_settings() {
local title="Networking"
local title2="Wifi Settings"
local title2="Wi-Fi Settings"
wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf"
while true; do
local option=""
option=$(dialog --menu "$title" 15 40 4 \
1 "View wifi settings" \
2 "Change wifi settings" \
3 "Restart wifi" \
1 "View Wi-Fi settings" \
2 "Change Wi-Fi settings" \
3 "Restart Wi-Fi" \
4 "View ethernet settings" \
5 "Set hostname" \
6 "Test internet connection" \
@ -57,14 +57,14 @@ networking_settings() {
case $option in
1)
echo "Getting wifi configuration..."
echo "Getting Wi-Fi configuration..."
dialog --msgbox "$(femto-network-config.sh -w)" 0 0
;;
2)
wifi_config
;;
3)
dialog --title "$title2" --yesno "Wifi and Ethernet will be restarted.\nMeshtastic wifi setting will be set to ON." 7 50
dialog --title "$title2" --yesno "Wi-Fi and Ethernet will be restarted.\nMeshtastic Wi-Fi setting will be set to ON." 7 50
if [ $? -eq 0 ]; then #unless cancel/no
femto-network-config.sh -r
fi
@ -183,7 +183,7 @@ then \`depmod\` will be run. To remove support, those modules will be deleted.\n
;;
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. \
set the eth0 MAC address and Meshtastic nodeID to a derivative of the CPU serial number and enable Wi-Fi 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
@ -442,7 +442,7 @@ while getopts ":lw" opt; do
l) # Option -l (set lora radio)
set_lora_radio
;;
w) # Option -w (wifi config)
w) # Option -w (Wi-Fi config)
wifi_config
;;
esac

View file

@ -27,7 +27,7 @@ wizard() {
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
dialog --title "$title" --cancel-label "Skip" --yesno "\nConfigure Wi-Fi settings?" 8 40
if [ $? -eq 0 ]; then #unless cancel/no
femto-config -w
fi
@ -52,9 +52,10 @@ wizard() {
fi
while true; do
choice=$(dialog --title "$title" --cancel-label "Skip" --menu "Enable/disable Meshtastic Legacy admin channel?" 11 40 5 \
choice=$(dialog --title "$title" --cancel-label "Skip" --menu "Enable/disable Meshtastic Legacy admin channel?" 12 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
@ -64,9 +65,9 @@ wizard() {
fi
case $choice in
1) femto-meshtasticd-config.sh -o "true" ;;
2) femto-meshtasticd-config.sh -o "false" ;;
3) return ;;
1) femto-meshtasticd-config.sh -o "true" && break ;;
2) femto-meshtasticd-config.sh -o "false" && break ;;
3) break ;;
*) dialog --msgbox "Invalid choice, please try again." 8 40 ;;
esac
done

View file

@ -8,16 +8,16 @@ wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf"
help=$(cat <<EOF
Options are:
-h This message
-s "SSID" Set wifi SSID
-p "PSK" Set wifi PSK (password)
-c "COUNTRY" Set wifi 2-letter country code (such as US, DE)
-r Restart wifi
-s "SSID" Set Wi-Fi SSID
-p "PSK" Set Wi-Fi PSK (password)
-c "COUNTRY" Set Wi-Fi 2-letter country code (such as US, DE)
-r Restart Wi-Fi
-e Get ethernet settings
-w Get wifi settings
-w Get Wi-Fi 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.
To set Wi-Fi settings, use -r as last argument to trigger reset after wpa_supplicant.conf is modified.
EOF
)
@ -72,16 +72,16 @@ MAC Address: $(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\
mesh_wifi_status="disabled"
fi
echo "\
SSID: $wifi_ssid\n\
Password: $wifi_psk\n\
Country: $wifi_country\n\
Meshtastic wifi: $mesh_wifi_status\n\
SSID: $wifi_ssid\n\
Password: $wifi_psk\n\
Country: $wifi_country\n\
Meshtastic Wi-Fi: $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\
Hostname: $(hostname).local\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\
Hostname: $(hostname).local\n\
For more details, enter \`iwconfig\`."
;;
t) # Option -t (test internet connection)
@ -103,7 +103,7 @@ For more details, enter \`iwconfig\`."
echo "Internet connection is up.\n\nPinged $(echo "${targets[*]}" | sed 's/ /, /g').\nReceived $successful/$total responses."
fi
;;
r) # Option -r (restart wifi)
r) # Option -r (restart Wi-Fi)
updated_wifi="true"
;;
n) # Option -n (set hostname)
@ -128,7 +128,7 @@ if [ "$updated_wifi" = true ]; then
systemctl restart wpa_supplicant
wpa_cli -i wlan0 reconfigure # <-------- add watch for FAIL response, error out
timeout 30s dhclient -v
echo " Wifi restarted. Enabling Meshtastic wifi setting."
echo " Wi-Fi restarted. Enabling Meshtastic Wi-Fi setting."
femto-meshtasticd-config.sh -m "--set network.wifi_enabled true" 10 "USB config" #| tee -a /tmp/femtofox-config.log
# if [ $? -eq 1 ]; then
# echo "Update of Meshtastic FAILED."