mirror of
https://github.com/femtofox/femtofox.git
synced 2026-10-26 19:02:00 -04:00
Cosmetic improvements to femto-config
This commit is contained in:
parent
5bd871754d
commit
fd756298da
2 changed files with 59 additions and 51 deletions
|
|
@ -44,18 +44,18 @@ 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 50 "$(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" --inputbox "Enter Wi-Fi Password:" 8 50 3>&1 1>&2 2>&3)
|
||||
wifi_country=$(dialog --title "$title2" --cancel-label "Skip" --inputbox "Enter Country Code (US, DE...):" 9 50 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current country
|
||||
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" --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 (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"
|
||||
if [ -z "$wifi_ssid" ]; then
|
||||
dialog --title "$title2" --msgbox "\nSSID is required to configure Wi-Fi." 8 50
|
||||
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: (hidden)\nCountry: $wifi_country\nMeshtastic Wi-Fi setting set to ON" 9 50
|
||||
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
|
||||
exit 0
|
||||
fi
|
||||
|
|
@ -68,7 +68,7 @@ networking_settings() {
|
|||
wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf"
|
||||
while true; do
|
||||
local option=""
|
||||
option=$(dialog --menu "$title" 15 50 4 \
|
||||
option=$(dialog --cancel-label "Back" --menu "$title" 15 40 4 \
|
||||
1 "Turn Wi-Fi on/off" \
|
||||
2 "View Wi-Fi settings" \
|
||||
3 "Change Wi-Fi settings" \
|
||||
|
|
@ -85,20 +85,24 @@ networking_settings() {
|
|||
|
||||
case $option in
|
||||
1) # Turn Wi-Fi on/off)
|
||||
while true; do
|
||||
choice=$(dialog --title "Wi-Fi Status" --menu "text" 9 50 5 \
|
||||
1 "Turn Wi-Fi on" \
|
||||
2 "Turn Wi-Fi off" 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-network-config.sh -x "up" && break ;;
|
||||
2) femto-network-config.sh -x "down" && break ;;
|
||||
*) dialog --msgbox "Invalid choice, please try again." 8 50 ;;
|
||||
esac
|
||||
done
|
||||
if ! ip link show wlan0 &>/dev/null; then
|
||||
dialog --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a wifi adapter connected?" 8 40
|
||||
else
|
||||
while true; do
|
||||
choice=$(dialog --cancel-label "Back" --title "Wi-Fi Status" --menu "Enable/disable Wi-Fi" 9 40 5 \
|
||||
1 "Turn Wi-Fi on" \
|
||||
2 "Turn Wi-Fi off" 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-network-config.sh -x "up" && break ;;
|
||||
2) femto-network-config.sh -x "down" && break ;;
|
||||
*) dialog --msgbox "Invalid choice, please try again." 8 40 ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
;;
|
||||
2) # View Wi-Fi settings)
|
||||
echo "Getting Wi-Fi configuration..."
|
||||
|
|
@ -112,21 +116,21 @@ networking_settings() {
|
|||
dialog --title "Ethernet (eth0) settings" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -e)")" 0 0
|
||||
;;
|
||||
5) # Restart networking)
|
||||
dialog --title "$title2" --yesno "Wi-Fi and Ethernet will be restarted.\nMeshtastic Wi-Fi setting will be set to ON.\n\nProceed?" 8 50
|
||||
dialog --title "$title2" --yesno "Wi-Fi and Ethernet will be restarted.\nMeshtastic Wi-Fi setting will be set to ON.\n\nProceed?" 8 40
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
femto-network-config.sh -r
|
||||
fi
|
||||
;;
|
||||
6) # set hostname)
|
||||
new_hostname=$(dialog --title "$title" --cancel-label "Skip" --inputbox "Enter new hostname:" 8 50 $(hostname) 3>&1 1>&2 2>&3)
|
||||
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 50
|
||||
dialog --title "$title" --msgbox "Femtofox is now reachable at\n$new_hostname.local" 8 40
|
||||
fi
|
||||
;;
|
||||
7) # Test internet connection)
|
||||
echo "Testing internet connection..."
|
||||
dialog --title "Internet connectivity test" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -t)")" 8 50
|
||||
dialog --title "Internet connectivity test" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -t)")" 8 40
|
||||
;;
|
||||
8)
|
||||
return
|
||||
|
|
@ -139,7 +143,7 @@ networking_settings() {
|
|||
femto_pinouts() {
|
||||
while true; do
|
||||
local option=""
|
||||
option=$(dialog --menu "Pinouts" 15 50 5 \
|
||||
option=$(dialog --cancel-label "Back" --menu "Pinouts" 15 40 5 \
|
||||
1 "Femtofox" \
|
||||
2 "Femtofox Zero" \
|
||||
3 "Femtofox Tiny" \
|
||||
|
|
@ -168,7 +172,7 @@ misc_settings() {
|
|||
local title="Misc Settings"
|
||||
while true; do
|
||||
local option=""
|
||||
option=$(dialog --menu "Misc Settings" 15 50 4 \
|
||||
option=$(dialog --cancel-label "Back" --menu "Misc Settings" 15 40 4 \
|
||||
1 "Set system timezone" \
|
||||
2 "Ham radio support" \
|
||||
3 "Re-run first-boot script" \
|
||||
|
|
@ -220,7 +224,7 @@ 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
|
||||
then \`depmod\` will be run. To remove support, those modules will be deleted.\n\nAfter installation, many redundant network interfaces will appear." 11 40
|
||||
#add code to choose add or remove
|
||||
cp /oem/usr/ko/ham/* /lib/modules/5.10.160/
|
||||
depmod -a 5.10.160
|
||||
|
|
@ -312,7 +316,7 @@ meshtasticd_settings() {
|
|||
local title="Meshtasticd Settings"
|
||||
while true; do
|
||||
local option=""
|
||||
option=$(dialog --menu "$title" 22 50 4 \
|
||||
option=$(dialog --cancel-label "Back" --menu "$title" 22 50 4 \
|
||||
1 "View current configuration URL & QR code" \
|
||||
2 "Set new configuration URL" \
|
||||
3 "View current lora radio selection" \
|
||||
|
|
@ -340,7 +344,7 @@ meshtasticd_settings() {
|
|||
pause
|
||||
;;
|
||||
2)
|
||||
newurl=$(dialog --title "Meshtastic URL" --cancel-label "Skip" --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 40 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
|
||||
|
|
@ -350,7 +354,7 @@ meshtasticd_settings() {
|
|||
fi
|
||||
;;
|
||||
3)
|
||||
dialog --title "LoRa radio" --msgbox "Currently configured LoRa radio: $(femto-meshtasticd-config.sh -k)" 6 50
|
||||
dialog --title "LoRa radio" --msgbox "Currently configured LoRa radio: $(femto-meshtasticd-config.sh -k)" 6 40
|
||||
;;
|
||||
4)
|
||||
set_lora_radio
|
||||
|
|
@ -360,7 +364,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" --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)
|
||||
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 40 3>&1 1>&2 2>&3)
|
||||
if [ -n "$key" ]; then #if a URL was entered
|
||||
femto-meshtasticd-config.sh -a "$key"
|
||||
pause
|
||||
|
|
@ -415,7 +419,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 the \"first boot script\" from the misc menu." 8 50
|
||||
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)
|
||||
|
|
@ -430,7 +434,7 @@ software_settings() {
|
|||
while true; do
|
||||
local title="Software"
|
||||
local option=""
|
||||
option=$(dialog --menu "$title" 0 0 6 \
|
||||
option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \
|
||||
1 "Meshing Around by SpudGudMan" \
|
||||
2 "The Comms Channel BBS (TC2BBS)" \
|
||||
"" ""\
|
||||
|
|
@ -474,7 +478,7 @@ help_menu() {
|
|||
while true; do
|
||||
local title="Help / About"
|
||||
local option=""
|
||||
option=$(dialog --menu "$title" 0 0 6 \
|
||||
option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \
|
||||
1 "About Femtofox" \
|
||||
2 "Display pinout" \
|
||||
3 "Femtofox licensing info - short" \
|
||||
|
|
@ -536,7 +540,7 @@ if [ -n "$1" ]; then
|
|||
fi
|
||||
# Main menu
|
||||
while true; do
|
||||
choice=$(dialog --title "$(date)" --menu "Femtofox Config" 15 50 5 \
|
||||
choice=$(dialog --title "$(date)" --cancel-label "Exit" --menu "Femtofox Config" 15 40 5 \
|
||||
1 "Settings wizard" \
|
||||
2 "Networking" \
|
||||
3 "Meshtasticd" \
|
||||
|
|
@ -559,6 +563,6 @@ while true; do
|
|||
5) software_settings ;;
|
||||
6) help_menu ;;
|
||||
7) break ;;
|
||||
*) dialog --msgbox "Invalid choice, please try again." 8 50 ;;
|
||||
*) dialog --msgbox "Invalid choice, please try again." 8 40 ;;
|
||||
esac
|
||||
done
|
||||
|
|
@ -77,24 +77,28 @@ Hostname: $(hostname).local"
|
|||
if [ "$(cat /etc/wifi_state.txt)" = "up" ]; then
|
||||
wifi_status="\033[4m\033[0;32menabled\033[0m"
|
||||
else
|
||||
if ip link show wlan0 &>/dev/null; then # if wlan0 exists
|
||||
wifi_status="\033[0;31mdisabled\033[0m"
|
||||
mac_address_line="MAC address: $(ifconfig wlan0 | grep ether | awk '{print $2}')\n\n"
|
||||
else
|
||||
wifi_status="\033[0;31mwlan0 not detected\033[0m"
|
||||
fi
|
||||
fi
|
||||
echo -e "\
|
||||
$(echo -e "\
|
||||
SSID: $(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)\n\
|
||||
Password: (hidden)\n\
|
||||
Country: $(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)\n\
|
||||
WiFi status: $wifi_status\n\
|
||||
\n\
|
||||
$(if [[ "$wifi_status" == *"enabled"* ]]; then
|
||||
echo -e "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"
|
||||
fi)")\n\
|
||||
Hostname: $(hostname).local\n\
|
||||
MAC address: $(ifconfig wlan0 | grep ether | awk '{print $2}')\n\
|
||||
\n\
|
||||
For more details, enter \`iwconfig\`."
|
||||
$(echo -e "\
|
||||
SSID: $(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)\n\
|
||||
Password: (hidden)\n\
|
||||
Country: $(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)\n\
|
||||
WiFi status: $wifi_status\
|
||||
\n\
|
||||
$(if [[ "$wifi_status" == *"enabled"* ]]; then
|
||||
echo -e "\nConnected 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"
|
||||
fi)")\n\
|
||||
Hostname: $(hostname).local\n\
|
||||
$mac_address_line
|
||||
For more details, enter \`iwconfig\`."
|
||||
;;
|
||||
t) # Option -t (test internet connection)
|
||||
# Define ping targets and initialize counter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue