From b3763de4d01e42dd3a3fc5404075f59eb6003e5e Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Fri, 29 May 2026 14:04:33 +0200 Subject: [PATCH 01/10] Fix netplan config script to work when there is no eth or wlan interfaces Before it would always append ethernets: or wifis: to the config file, even if there are such interfaces found, resulting in a syntax error when applying --- subscripts/4Network/2Configure_netplan.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subscripts/4Network/2Configure_netplan.sh b/subscripts/4Network/2Configure_netplan.sh index 1956073..7fe719b 100755 --- a/subscripts/4Network/2Configure_netplan.sh +++ b/subscripts/4Network/2Configure_netplan.sh @@ -72,7 +72,6 @@ touch $FILENAME echo "network:" >> /tmp/01-netcfg.yaml echo " version: 2" >> /tmp/01-netcfg.yaml echo " renderer: networkd" >> /tmp/01-netcfg.yaml -echo " ethernets:" >> /tmp/01-netcfg.yaml interfaces=$(ls /sys/class/net) # interfaces="eth0 eth1 wlan0 wlan1" @@ -83,6 +82,7 @@ wlans=$(echo $interfaces | grep -o "\w*wlan\w*") if [ -z "${eths}" ]; then error_msg "No Ethernet interfaces found! (looking for eth0, eth1 ...).\nYour Ethernet interfaces may have different names, run the Network Interface Names Fix first.\n\n\n Continuing with Wi-Fi config. " else + echo " ethernets:" >> /tmp/01-netcfg.yaml for name in ${eths}; do echo " $name:" >> /tmp/01-netcfg.yaml @@ -103,11 +103,12 @@ else done fi -echo " wifis:" >> /tmp/01-netcfg.yaml if [ -z "${wlans}" ]; then error_msg "No Wlan interfaces found! (looking for wlan0, wlan1 ...).\nYour Wlan interfaces may have different names, run the Network Interface Names Fix first.\n\n\n" else + echo " wifis:" >> /tmp/01-netcfg.yaml + for name in ${wlans}; do echo " $name:" >> /tmp/01-netcfg.yaml From 27b72615b7a028969c3bf3f8feb4b6917649da02 Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Fri, 29 May 2026 14:53:23 +0200 Subject: [PATCH 02/10] Disable network manager immediately when configuring networking --- ...re_netplan.sh => 2Configure_networking.sh} | 71 +++++++++++++------ .../3Disable_network_manager_(do_on_UAVs).sh | 32 --------- ...anager.sh => 3Reenable_network_manager.sh} | 21 +++--- 3 files changed, 60 insertions(+), 64 deletions(-) rename subscripts/4Network/{2Configure_netplan.sh => 2Configure_networking.sh} (61%) delete mode 100755 subscripts/4Network/3Disable_network_manager_(do_on_UAVs).sh rename subscripts/4Network/{4Reenable_network_manager.sh => 3Reenable_network_manager.sh} (60%) diff --git a/subscripts/4Network/2Configure_netplan.sh b/subscripts/4Network/2Configure_networking.sh similarity index 61% rename from subscripts/4Network/2Configure_netplan.sh rename to subscripts/4Network/2Configure_networking.sh index 7fe719b..f76b969 100755 --- a/subscripts/4Network/2Configure_netplan.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -1,7 +1,7 @@ #!/bin/bash yesno_def_no () { - whiptail --title "Netplan Config" --yesno "$1" --yes-button "No" --no-button "Yes" 0 0 + whiptail --title "Network Config" --yesno "$1" --yes-button "No" --no-button "Yes" 0 0 ret_val=$? if [ $ret_val -eq 255 ]; then @@ -18,7 +18,7 @@ yesno_def_no () { } yesno_def_yes () { - whiptail --title "Netplan Config" --yesno "$1" 0 0 + whiptail --title "Network Config" --yesno "$1" 0 0 ret_val=$? if [ $ret_val -eq 255 ]; then @@ -55,10 +55,30 @@ input_box () { } error_msg () { - whiptail --title "Netplan config" --msgbox "$1" 0 0 + whiptail --title "Network config" --msgbox "$1" 0 0 } -yesno_def_yes "Delete any previous netplan configs? (Recommended)" +enable_systemd_networkd () { + sudo systemctl unmask systemd-networkd systemd-resolved + sudo systemctl enable --now systemd-networkd systemd-resolved +} + +disable_network_manager () { + sudo systemctl disable --now NetworkManager NetworkManager-wait-online NetworkManager-dispatcher + sudo systemctl mask NetworkManager NetworkManager-wait-online NetworkManager-dispatcher +} + +yesno_def_yes "This script will configure networking on the device. Systemd-networkd will be used as the backend for netplan and NetworkManager will be disabled. If you're connected via SSH you may lose connection when applying. Do you want to continue?" +ret_val=$? + +if [ $ret_val -eq 1 ]; then + echo "Continuing with network config..." +elif [ $ret_val -eq 0 ]; then + echo "Aborting network config..." + exit 0 +fi + +yesno_def_yes "Delete all previous netplan configs? (Recommended)" ret_val=$? if [ $ret_val -eq 1 ]; then @@ -74,7 +94,6 @@ echo " version: 2" >> /tmp/01-netcfg.yaml echo " renderer: networkd" >> /tmp/01-netcfg.yaml interfaces=$(ls /sys/class/net) -# interfaces="eth0 eth1 wlan0 wlan1" eths=$(echo $interfaces | grep -o "\w*eth\w*") wlans=$(echo $interfaces | grep -o "\w*wlan\w*") @@ -83,10 +102,10 @@ if [ -z "${eths}" ]; then error_msg "No Ethernet interfaces found! (looking for eth0, eth1 ...).\nYour Ethernet interfaces may have different names, run the Network Interface Names Fix first.\n\n\n Continuing with Wi-Fi config. " else echo " ethernets:" >> /tmp/01-netcfg.yaml - for name in ${eths}; do - echo " $name:" >> /tmp/01-netcfg.yaml + for int in ${eths}; do + echo " $int:" >> /tmp/01-netcfg.yaml - yesno_def_no "Do you want to use DHCP on $name?" + yesno_def_no "Do you want to use DHCP on $int?" ret_val=$? if [ $ret_val -eq 1 ]; then @@ -96,7 +115,7 @@ else echo " dhcp4: no" >> /tmp/01-netcfg.yaml echo " dhcp6: no" >> /tmp/01-netcfg.yaml - address=$(input_box "Enter your static IP address:" "10.10.20.101") + address=$(input_box "Enter your static IP address for $int:" "10.10.20.101") echo " addresses: [$address/24]" >> /tmp/01-netcfg.yaml fi @@ -109,10 +128,10 @@ if [ -z "${wlans}" ]; then else echo " wifis:" >> /tmp/01-netcfg.yaml - for name in ${wlans}; do - echo " $name:" >> /tmp/01-netcfg.yaml + for int in ${wlans}; do + echo " $int:" >> /tmp/01-netcfg.yaml - yesno_def_no "Do you want to use DHCP on $name?" + yesno_def_no "Do you want to use DHCP on $int?" dhcp=$? if [ $dhcp -eq 1 ]; then @@ -124,17 +143,17 @@ else address="" if [ $1 = "f4f" ]; then - address=$(input_box "Enter your static IP address:" "192.168.12.101") + address=$(input_box "Enter your static IP address for $int:" "192.168.12.101") else - address=$(input_box "Enter your static IP address:" "192.168.69.101") + address=$(input_box "Enter your static IP address for $int:" "192.168.69.101") fi echo " addresses: [$address/24]" >> /tmp/01-netcfg.yaml gateway="" if [ $1 = "f4f" ]; then - gateway=$(input_box "Enter your gateway address:" "192.168.12.1") + gateway=$(input_box "Enter your default gateway address:" "192.168.12.1") else - gateway=$(input_box "Enter your gateway address:" "192.168.69.1") + gateway=$(input_box "Enter your default gateway address:" "192.168.69.1") fi echo " gateway4: $gateway" >> /tmp/01-netcfg.yaml @@ -142,15 +161,15 @@ else ap_name="" if [ $1 = "f4f" ]; then - ap_name=$(input_box "Enter your access point name:" "f4f_robot") + ap_name=$(input_box "Enter your WiFi name (SSID):" "f4f_robot") else - ap_name=$(input_box "Enter your access point name:" "mrs_ctu") + ap_name=$(input_box "Enter your WiFi name (SSID):" "mrs_ctu") fi echo " access-points:" >> /tmp/01-netcfg.yaml echo " \"$ap_name\":" >> /tmp/01-netcfg.yaml - password=$(input_box "Enter your access point password:" "mikrokopter") + password=$(input_box "Enter your WiFi password:" "mikrokopter") echo " password: \"$password\"" >> /tmp/01-netcfg.yaml if [ $dhcp -eq 0 ]; then @@ -163,14 +182,26 @@ else fi netplan=$(cat /tmp/01-netcfg.yaml); -yesno_def_yes "This netplan was generated: \n\n $netplan \n\n Copy to /etc/netplan and Apply?" +yesno_def_yes "The following netplan was generated: \n\n $netplan \n\n Copy to /etc/netplan and Apply?" ret_val=$? if [ $ret_val -eq 1 ]; then + + # First ensure systemd-networkd is enabled and running + echo "Enabling systemd-networkd ..." + enable_systemd_networkd + + # Then apply the netplan config echo "Copying netplan ..." sudo cp /tmp/01-netcfg.yaml /etc/netplan echo "Applying netplan ..." + sudo netplan generate sudo netplan apply + + # Finally, disable network manager + echo "Disabling NetworkManager ..." + disable_network_manager + echo "Done" exit 0 fi diff --git a/subscripts/4Network/3Disable_network_manager_(do_on_UAVs).sh b/subscripts/4Network/3Disable_network_manager_(do_on_UAVs).sh deleted file mode 100755 index 1a6ae86..0000000 --- a/subscripts/4Network/3Disable_network_manager_(do_on_UAVs).sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -whiptail --title "Disable Network Manager" --yesno "This script will disable Network Manager and apply your netplan config. If you are connected through SSH, you will probably lose connection. Also if you do not have a netplan config already set-up, the computer will not reconnect to your WiFi.\n\n\n Proceed?" --yes-button "No" --no-button "Yes" 15 60 -ret_val=$? - -if [ $ret_val -eq 255 ]; then - exit 1 -elif [ $ret_val -eq 1 ]; then - - sudo systemctl stop NetworkManager.service - sudo systemctl disable NetworkManager.service - - sudo systemctl stop NetworkManager-wait-online.service - sudo systemctl disable NetworkManager-wait-online.service - - sudo systemctl stop NetworkManager-dispatcher.service - sudo systemctl disable NetworkManager-dispatcher.service - - sudo systemctl stop network-manager.service - sudo systemctl disable network-manager.service - - sudo netplan apply - - echo "Network manager disabled" - exit 0 -elif [ $ret_val -eq 0 ]; then - exit 1 -else - echo "Error state" - exit 0 -fi - diff --git a/subscripts/4Network/4Reenable_network_manager.sh b/subscripts/4Network/3Reenable_network_manager.sh similarity index 60% rename from subscripts/4Network/4Reenable_network_manager.sh rename to subscripts/4Network/3Reenable_network_manager.sh index 946c15c..4d729eb 100755 --- a/subscripts/4Network/4Reenable_network_manager.sh +++ b/subscripts/4Network/3Reenable_network_manager.sh @@ -1,34 +1,31 @@ #!/bin/bash -whiptail --title "Reenable Network Manager" --yesno "This script will reenable Network Manager and delete all your netplan configs. If you are connected through SSH, you will lose connection and you will not regain it automatically. You willuprobably have to reconfigure all the network configurations.\n\n\n Proceed?" --yes-button "No" --no-button "Yes" 15 60 +whiptail --title "Reenable Network Manager" --yesno "This script will reenable Network Manager and delete all your netplan configs. If you are connected through SSH, you will lose connection and you will not regain it automatically. You will probably have to reconfigure all the network configurations.\n\n\n Proceed?" --yes-button "No" --no-button "Yes" 15 60 ret_val=$? if [ $ret_val -eq 255 ]; then exit 1 elif [ $ret_val -eq 1 ]; then - sudo systemctl enable NetworkManager.service - sudo systemctl start NetworkManager.service + sudo systemctl unmask NetworkManager NetworkManager-wait-online NetworkManager-dispatcher + sudo systemctl enable --now NetworkManager NetworkManager-wait-online NetworkManager-dispatcher - sudo systemctl enable NetworkManager-wait-online.service - sudo systemctl start NetworkManager-wait-online.service - - sudo systemctl enable NetworkManager-dispatcher.service - sudo systemctl start NetworkManager-dispatcher.service - - sudo systemctl enable network-manager.service - sudo systemctl start network-manager.service + sudo systemctl disable --now systemd-networkd systemd-resolved + sudo systemctl mask systemd-networkd systemd-resolved sudo rm /etc/netplan/* FILENAME=/tmp/01-network-manager-all.yaml - rm $FILENAME + rm $FILENAME 2> /dev/null touch $FILENAME echo "network:" >> $FILENAME echo " version: 2" >> $FILENAME echo " renderer: NetworkManager" >> $FILENAME sudo cp $FILENAME /etc/netplan + sudo netplan generate + sudo netplan apply + echo "Network manager enabled" exit 0 elif [ $ret_val -eq 0 ]; then From 7a6d8816fad4115a7d62e72cf9769d63631aa73f Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Mon, 1 Jun 2026 09:36:09 +0200 Subject: [PATCH 03/10] Install netplan if not installed yet --- subscripts/4Network/2Configure_networking.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subscripts/4Network/2Configure_networking.sh b/subscripts/4Network/2Configure_networking.sh index f76b969..c44ddc0 100755 --- a/subscripts/4Network/2Configure_networking.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -68,6 +68,12 @@ disable_network_manager () { sudo systemctl mask NetworkManager NetworkManager-wait-online NetworkManager-dispatcher } +# If netplan is not installed, install it +if ! command -v netplan &> /dev/null; then + echo "Netplan not found, installing..." + sudo apt update && sudo apt install -y netplan.io +fi + yesno_def_yes "This script will configure networking on the device. Systemd-networkd will be used as the backend for netplan and NetworkManager will be disabled. If you're connected via SSH you may lose connection when applying. Do you want to continue?" ret_val=$? From febfd8157d3e5a7d86860a899716b23c211e01ca Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Mon, 1 Jun 2026 09:50:55 +0200 Subject: [PATCH 04/10] Copilot fixes --- subscripts/4Network/2Configure_networking.sh | 10 +++++----- subscripts/4Network/3Reenable_network_manager.sh | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/subscripts/4Network/2Configure_networking.sh b/subscripts/4Network/2Configure_networking.sh index c44ddc0..55ee6cd 100755 --- a/subscripts/4Network/2Configure_networking.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -88,12 +88,12 @@ yesno_def_yes "Delete all previous netplan configs? (Recommended)" ret_val=$? if [ $ret_val -eq 1 ]; then - sudo rm /etc/netplan/* + sudo rm -f /etc/netplan/*.yaml fi FILENAME=/tmp/01-netcfg.yaml -rm $FILENAME +rm -f -- "$FILENAME" touch $FILENAME echo "network:" >> /tmp/01-netcfg.yaml echo " version: 2" >> /tmp/01-netcfg.yaml @@ -148,7 +148,7 @@ else echo " dhcp6: no" >> /tmp/01-netcfg.yaml address="" - if [ $1 = "f4f" ]; then + if [[ "$1" == "f4f" ]]; then address=$(input_box "Enter your static IP address for $int:" "192.168.12.101") else address=$(input_box "Enter your static IP address for $int:" "192.168.69.101") @@ -156,7 +156,7 @@ else echo " addresses: [$address/24]" >> /tmp/01-netcfg.yaml gateway="" - if [ $1 = "f4f" ]; then + if [[ "$1" == "f4f" ]]; then gateway=$(input_box "Enter your default gateway address:" "192.168.12.1") else gateway=$(input_box "Enter your default gateway address:" "192.168.69.1") @@ -166,7 +166,7 @@ else fi ap_name="" - if [ $1 = "f4f" ]; then + if [[ "$1" == "f4f" ]]; then ap_name=$(input_box "Enter your WiFi name (SSID):" "f4f_robot") else ap_name=$(input_box "Enter your WiFi name (SSID):" "mrs_ctu") diff --git a/subscripts/4Network/3Reenable_network_manager.sh b/subscripts/4Network/3Reenable_network_manager.sh index 4d729eb..6a8ffc7 100755 --- a/subscripts/4Network/3Reenable_network_manager.sh +++ b/subscripts/4Network/3Reenable_network_manager.sh @@ -10,13 +10,15 @@ elif [ $ret_val -eq 1 ]; then sudo systemctl unmask NetworkManager NetworkManager-wait-online NetworkManager-dispatcher sudo systemctl enable --now NetworkManager NetworkManager-wait-online NetworkManager-dispatcher - sudo systemctl disable --now systemd-networkd systemd-resolved - sudo systemctl mask systemd-networkd systemd-resolved + sudo systemctl disable --now systemd-networkd + sudo systemctl mask systemd-networkd + sudo systemctl unmask systemd-resolved + sudo systemctl enable --now systemd-resolved - sudo rm /etc/netplan/* + sudo rm -f /etc/netplan/*.yaml FILENAME=/tmp/01-network-manager-all.yaml - rm $FILENAME 2> /dev/null + rm -f -- "$FILENAME" touch $FILENAME echo "network:" >> $FILENAME echo " version: 2" >> $FILENAME From 6b64cd8ebab901e81b6dfbb5af3bd41af8b36bcd Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Mon, 1 Jun 2026 11:05:25 +0200 Subject: [PATCH 05/10] Migrate to newer default gateway syntax gateway4 is deprecated --- subscripts/4Network/2Configure_networking.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subscripts/4Network/2Configure_networking.sh b/subscripts/4Network/2Configure_networking.sh index 55ee6cd..5b9e02f 100755 --- a/subscripts/4Network/2Configure_networking.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -161,7 +161,9 @@ else else gateway=$(input_box "Enter your default gateway address:" "192.168.69.1") fi - echo " gateway4: $gateway" >> /tmp/01-netcfg.yaml + echo " routes:" >>/tmp/01-netcfg.yaml + echo " - to: default" >>/tmp/01-netcfg.yaml + echo " via: $gateway" >>/tmp/01-netcfg.yaml fi From 53091e6ee26074f37d591327fccd41fe71ae9f5d Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Mon, 1 Jun 2026 11:05:53 +0200 Subject: [PATCH 06/10] Reformat --- subscripts/4Network/2Configure_networking.sh | 72 ++++++++++---------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/subscripts/4Network/2Configure_networking.sh b/subscripts/4Network/2Configure_networking.sh index 5b9e02f..06e4019 100755 --- a/subscripts/4Network/2Configure_networking.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -1,6 +1,6 @@ #!/bin/bash -yesno_def_no () { +yesno_def_no() { whiptail --title "Network Config" --yesno "$1" --yes-button "No" --no-button "Yes" 0 0 ret_val=$? @@ -17,8 +17,8 @@ yesno_def_no () { fi } -yesno_def_yes () { - whiptail --title "Network Config" --yesno "$1" 0 0 +yesno_def_yes() { + whiptail --title "Network Config" --yesno "$1" 0 0 ret_val=$? if [ $ret_val -eq 255 ]; then @@ -34,7 +34,7 @@ yesno_def_yes () { fi } -input_box () { +input_box() { tmp=$(whiptail --inputbox "$1" 0 0 "$2" 3>&1 1>&2 2>&3) ret_val=$? @@ -54,22 +54,22 @@ input_box () { fi } -error_msg () { +error_msg() { whiptail --title "Network config" --msgbox "$1" 0 0 } -enable_systemd_networkd () { +enable_systemd_networkd() { sudo systemctl unmask systemd-networkd systemd-resolved sudo systemctl enable --now systemd-networkd systemd-resolved } -disable_network_manager () { +disable_network_manager() { sudo systemctl disable --now NetworkManager NetworkManager-wait-online NetworkManager-dispatcher sudo systemctl mask NetworkManager NetworkManager-wait-online NetworkManager-dispatcher } # If netplan is not installed, install it -if ! command -v netplan &> /dev/null; then +if ! command -v netplan &>/dev/null; then echo "Netplan not found, installing..." sudo apt update && sudo apt install -y netplan.io fi @@ -91,74 +91,72 @@ if [ $ret_val -eq 1 ]; then sudo rm -f /etc/netplan/*.yaml fi - FILENAME=/tmp/01-netcfg.yaml rm -f -- "$FILENAME" touch $FILENAME -echo "network:" >> /tmp/01-netcfg.yaml -echo " version: 2" >> /tmp/01-netcfg.yaml -echo " renderer: networkd" >> /tmp/01-netcfg.yaml +echo "network:" >>/tmp/01-netcfg.yaml +echo " version: 2" >>/tmp/01-netcfg.yaml +echo " renderer: networkd" >>/tmp/01-netcfg.yaml interfaces=$(ls /sys/class/net) eths=$(echo $interfaces | grep -o "\w*eth\w*") wlans=$(echo $interfaces | grep -o "\w*wlan\w*") - if [ -z "${eths}" ]; then error_msg "No Ethernet interfaces found! (looking for eth0, eth1 ...).\nYour Ethernet interfaces may have different names, run the Network Interface Names Fix first.\n\n\n Continuing with Wi-Fi config. " else - echo " ethernets:" >> /tmp/01-netcfg.yaml + echo " ethernets:" >>/tmp/01-netcfg.yaml + for int in ${eths}; do - echo " $int:" >> /tmp/01-netcfg.yaml + echo " $int:" >>/tmp/01-netcfg.yaml yesno_def_no "Do you want to use DHCP on $int?" ret_val=$? if [ $ret_val -eq 1 ]; then - echo " dhcp4: yes" >> /tmp/01-netcfg.yaml - echo " dhcp6: no" >> /tmp/01-netcfg.yaml + echo " dhcp4: yes" >>/tmp/01-netcfg.yaml + echo " dhcp6: no" >>/tmp/01-netcfg.yaml elif [ $ret_val -eq 0 ]; then - echo " dhcp4: no" >> /tmp/01-netcfg.yaml - echo " dhcp6: no" >> /tmp/01-netcfg.yaml + echo " dhcp4: no" >>/tmp/01-netcfg.yaml + echo " dhcp6: no" >>/tmp/01-netcfg.yaml address=$(input_box "Enter your static IP address for $int:" "10.10.20.101") - echo " addresses: [$address/24]" >> /tmp/01-netcfg.yaml + echo " addresses: [$address/24]" >>/tmp/01-netcfg.yaml fi done fi - if [ -z "${wlans}" ]; then error_msg "No Wlan interfaces found! (looking for wlan0, wlan1 ...).\nYour Wlan interfaces may have different names, run the Network Interface Names Fix first.\n\n\n" else - echo " wifis:" >> /tmp/01-netcfg.yaml + echo " wifis:" >>/tmp/01-netcfg.yaml for int in ${wlans}; do - echo " $int:" >> /tmp/01-netcfg.yaml + echo " $int:" >>/tmp/01-netcfg.yaml yesno_def_no "Do you want to use DHCP on $int?" dhcp=$? if [ $dhcp -eq 1 ]; then - echo " dhcp4: yes" >> /tmp/01-netcfg.yaml - echo " dhcp6: no" >> /tmp/01-netcfg.yaml + echo " dhcp4: yes" >>/tmp/01-netcfg.yaml + echo " dhcp6: no" >>/tmp/01-netcfg.yaml elif [ $dhcp -eq 0 ]; then - echo " dhcp4: no" >> /tmp/01-netcfg.yaml - echo " dhcp6: no" >> /tmp/01-netcfg.yaml + echo " dhcp4: no" >>/tmp/01-netcfg.yaml + echo " dhcp6: no" >>/tmp/01-netcfg.yaml address="" if [[ "$1" == "f4f" ]]; then address=$(input_box "Enter your static IP address for $int:" "192.168.12.101") - else + else address=$(input_box "Enter your static IP address for $int:" "192.168.69.101") fi - echo " addresses: [$address/24]" >> /tmp/01-netcfg.yaml + echo " addresses: [$address/24]" >>/tmp/01-netcfg.yaml gateway="" if [[ "$1" == "f4f" ]]; then gateway=$(input_box "Enter your default gateway address:" "192.168.12.1") - else + else gateway=$(input_box "Enter your default gateway address:" "192.168.69.1") fi echo " routes:" >>/tmp/01-netcfg.yaml @@ -170,26 +168,26 @@ else ap_name="" if [[ "$1" == "f4f" ]]; then ap_name=$(input_box "Enter your WiFi name (SSID):" "f4f_robot") - else + else ap_name=$(input_box "Enter your WiFi name (SSID):" "mrs_ctu") fi - echo " access-points:" >> /tmp/01-netcfg.yaml - echo " \"$ap_name\":" >> /tmp/01-netcfg.yaml + echo " access-points:" >>/tmp/01-netcfg.yaml + echo " \"$ap_name\":" >>/tmp/01-netcfg.yaml password=$(input_box "Enter your WiFi password:" "mikrokopter") - echo " password: \"$password\"" >> /tmp/01-netcfg.yaml + echo " password: \"$password\"" >>/tmp/01-netcfg.yaml if [ $dhcp -eq 0 ]; then dns=$(input_box "Enter your DNS server address:" "8.8.8.8") - echo " nameservers:" >> /tmp/01-netcfg.yaml - echo " addresses: [$dns]" >> /tmp/01-netcfg.yaml + echo " nameservers:" >>/tmp/01-netcfg.yaml + echo " addresses: [$dns]" >>/tmp/01-netcfg.yaml fi done fi -netplan=$(cat /tmp/01-netcfg.yaml); +netplan=$(cat /tmp/01-netcfg.yaml) yesno_def_yes "The following netplan was generated: \n\n $netplan \n\n Copy to /etc/netplan and Apply?" ret_val=$? From 2496461bf0b9e3bab4ecc238801f09417bb54ac1 Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Mon, 1 Jun 2026 11:06:38 +0200 Subject: [PATCH 07/10] Add default gateway prompt for eth --- subscripts/4Network/2Configure_networking.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subscripts/4Network/2Configure_networking.sh b/subscripts/4Network/2Configure_networking.sh index 06e4019..36f5b0e 100755 --- a/subscripts/4Network/2Configure_networking.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -123,6 +123,10 @@ else address=$(input_box "Enter your static IP address for $int:" "10.10.20.101") echo " addresses: [$address/24]" >>/tmp/01-netcfg.yaml + gateway=$(input_box "Enter your default gateway address for $int:" "10.10.20.1") + echo " routes:" >>/tmp/01-netcfg.yaml + echo " - to: default" >>/tmp/01-netcfg.yaml + echo " via: $gateway" >>/tmp/01-netcfg.yaml fi done fi From 5fc6050d0984ea27f1f697deabd2aa1cbcbbf0ce Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Mon, 1 Jun 2026 11:14:29 +0200 Subject: [PATCH 08/10] Ensure netplan config file has correct permissions --- subscripts/4Network/2Configure_networking.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/subscripts/4Network/2Configure_networking.sh b/subscripts/4Network/2Configure_networking.sh index 36f5b0e..23fbdf4 100755 --- a/subscripts/4Network/2Configure_networking.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -204,6 +204,7 @@ if [ $ret_val -eq 1 ]; then # Then apply the netplan config echo "Copying netplan ..." sudo cp /tmp/01-netcfg.yaml /etc/netplan + sudo chmod 600 /etc/netplan/01-netcfg.yaml echo "Applying netplan ..." sudo netplan generate sudo netplan apply From d4ea94ef6fba2bd9bf5a95afb88616ab7aa323ca Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Mon, 1 Jun 2026 11:17:35 +0200 Subject: [PATCH 09/10] Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- subscripts/4Network/2Configure_networking.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/subscripts/4Network/2Configure_networking.sh b/subscripts/4Network/2Configure_networking.sh index 23fbdf4..52e4d68 100755 --- a/subscripts/4Network/2Configure_networking.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -46,7 +46,7 @@ input_box() { exit 1 elif [ $ret_val -eq 0 ]; then # valid input - echo $tmp #this will output the string that is user input, and we can capture it into a variable - e.g. foo=$(input_box) + printf '%s\n' "$tmp" # this outputs the user input so callers can capture it (e.g. foo=$(input_box ...) return 0 else echo "Error state" @@ -93,14 +93,13 @@ fi FILENAME=/tmp/01-netcfg.yaml rm -f -- "$FILENAME" -touch $FILENAME -echo "network:" >>/tmp/01-netcfg.yaml -echo " version: 2" >>/tmp/01-netcfg.yaml -echo " renderer: networkd" >>/tmp/01-netcfg.yaml - -interfaces=$(ls /sys/class/net) -eths=$(echo $interfaces | grep -o "\w*eth\w*") -wlans=$(echo $interfaces | grep -o "\w*wlan\w*") +touch -- "$FILENAME" +echo "network:" >>"$FILENAME" +echo " version: 2" >>"$FILENAME" +echo " renderer: networkd" >>"$FILENAME" + +eths=$(ls /sys/class/net | grep -E '^eth') +wlans=$(ls /sys/class/net | grep -E '^wlan') if [ -z "${eths}" ]; then error_msg "No Ethernet interfaces found! (looking for eth0, eth1 ...).\nYour Ethernet interfaces may have different names, run the Network Interface Names Fix first.\n\n\n Continuing with Wi-Fi config. " From d8db0499e03ea9bc27341ebeac6d2f82de58722b Mon Sep 17 00:00:00 2001 From: Vid Smole Date: Mon, 1 Jun 2026 11:25:53 +0200 Subject: [PATCH 10/10] Ask for DNS server on eth --- subscripts/4Network/2Configure_networking.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subscripts/4Network/2Configure_networking.sh b/subscripts/4Network/2Configure_networking.sh index 52e4d68..2b20d4b 100755 --- a/subscripts/4Network/2Configure_networking.sh +++ b/subscripts/4Network/2Configure_networking.sh @@ -126,6 +126,10 @@ else echo " routes:" >>/tmp/01-netcfg.yaml echo " - to: default" >>/tmp/01-netcfg.yaml echo " via: $gateway" >>/tmp/01-netcfg.yaml + + dns=$(input_box "Enter your DNS server address for $int:" "8.8.8.8") + echo " nameservers:" >>/tmp/01-netcfg.yaml + echo " addresses: [$dns]" >>/tmp/01-netcfg.yaml fi done fi