Fix issue with PSKs not interpreting special characters correctly

And a few other small improvements in the network settings wifi configuration menus
This commit is contained in:
nagumii 2025-01-04 17:26:25 +02:00
parent 01a926f1e1
commit 5191eef715
4 changed files with 22 additions and 22 deletions

View file

@ -15,8 +15,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 " For settings, run \`\033[0;31msudo femto-config\033[0m\`\n"
printf " Made for Femtofox https://www.femtofox.com\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"
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

@ -2,9 +2,10 @@ ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
# the first network in this file is the one edited by the various UIs and tools (USB config, femto-config, web UI, femto-network-config.sh...)
network={
ssid="home"
ssid="ssid"
psk="password"
key_mgmt=WPA-PSK
priority=100
priority=100
}

View file

@ -1,7 +1,7 @@
#!/bin/bash
# prevents weirdness over tty
export NCURSES_NO_UTF8_ACS=1
export TERM=xterm-256color
export TERM=xterm-8color
export LANG=C.UTF-8
if [[ $EUID -ne 0 ]]; then
@ -20,9 +20,9 @@ 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)
wifi_ssid=$(dialog --title "$title2" --cancel-label "Skip" --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 --title "$title2" --cancel-label "Skip" --passwordbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3)
wifi_country=$(dialog --title "$title2" --cancel-label "Skip" --inputbox "Enter Country Code (US, DE...):" 9 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\""
[ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\""
cmd="$cmd -r"
@ -31,7 +31,10 @@ wifi_config() {
return
fi
eval $cmd
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
dialog --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: (hidden)\nCountry: $wifi_country\nMeshtastic Wi-Fi setting set to ON" 9 40
if [ "$1" = "-w" ]; then # if script was run with an argument that called this function, exit after completion
exit 0
fi
}
# Function to handle Wi-Fi settings
@ -182,12 +185,7 @@ then \`depmod\` will be run. To remove support, those modules will be deleted.\n
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 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
fi
femto-runonce.sh
;;
4)
luckfox-config
@ -266,6 +264,9 @@ set_lora_radio() {
return
fi
done
if [ "$1" = "-l" ]; then # if script was run with an argument that called this function, exit after completion
exit 0
fi
}
# Function to handle Meshtasticd settings
@ -376,7 +377,7 @@ meshtasticd_settings() {
dialog --title "$title" --yesno "Uninstall Meshtasticd?\n\nFoxbuntu was designed with Meshtasticd integration in mind, and may behave unexpectedly if Meshtasticd is removed." 0 0
if [ $? -eq 0 ]; then
femto-meshtasticd-config.sh -x
dialog --msgbox "Meshtasticd uninstalled. To purge all remnants, run \`sudo apt purge\`.\nAfter reinstallation but before first launch, run \`sudo runonce.sh\`." 8 40
dialog --msgbox "Meshtasticd uninstalled. To purge all remnants, run \`sudo apt purge\`.\nAfter reinstallation but before first launch, run the \"first boot script\" from the misc menu." 8 40
fi
;;
15)
@ -492,11 +493,9 @@ while getopts ":lw" opt; do
;;
esac
done
if [ -n "$1" ]; then
exit
fi
# Main menu
while true; do
choice=$(dialog --title "$(date)" --menu "Femtofox Config" 15 40 5 \

View file

@ -45,9 +45,9 @@ while getopts ":hs:p:c:ewn:tr" opt; do
echo "Setting SSID to $OPTARG."
updated_wifi="true"
;;
p) # Option -p (psk)
sed -i "/psk=/s/\".*\"/\"$OPTARG\"/" "$wpa_supplicant_conf"
echo "Setting PSK to $OPTARG."
p) # Option -p (psk)
sed -i "/psk=/s/\".*\"/\"$(echo "$OPTARG" | sed 's/&/\\&/g')\"/" "$wpa_supplicant_conf"
echo "Setting PSK to (hidden)."
updated_wifi="true"
;;
c) # Option -c (country)
@ -73,7 +73,7 @@ MAC Address: $(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\
fi
echo "\
SSID: $wifi_ssid\n\
Password: $wifi_psk\n\
Password: (hidden)\n\
Country: $wifi_country\n\
Meshtastic Wi-Fi: $mesh_wifi_status\n\
\n\