Simplify networking#6
Conversation
…aces
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
There was a problem hiding this comment.
Pull request overview
This PR streamlines device network setup by removing the standalone “Disable NetworkManager” step and integrating NetworkManager disablement directly into the netplan configuration flow, while also improving behavior when only Ethernet or only Wi‑Fi interfaces are present.
Changes:
- Removed the dedicated “Disable NetworkManager” script and folded its responsibilities into the netplan configuration step.
- Updated the networking configuration script to generate netplan YAML with conditional
ethernets:/wifis:sections and to enablesystemd-networkdbefore applying. - Updated the “Reenable NetworkManager” script to unmask/enable NetworkManager services and apply a NetworkManager-rendered netplan.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
subscripts/4Network/2Configure_networking.sh |
Integrates NetworkManager disablement into netplan apply and improves interface-specific netplan generation. |
subscripts/4Network/3Reenable_network_manager.sh |
Adjusts service toggling and applies a NetworkManager netplan renderer. |
subscripts/4Network/3Disable_network_manager_(do_on_UAVs).sh |
Removed to simplify workflow (step now integrated elsewhere). |
Comments suppressed due to low confidence (21)
subscripts/4Network/2Configure_networking.sh:149
if [ $1 = "f4f" ]will error with "unary operator expected" when the script is run without a first argument (common when invoked from a menu). Quote$1(or use[[ ... ]]) in these comparisons so empty args are handled safely.
subscripts/4Network/2Configure_networking.sh:157- Same issue as above: unquoted
$1in a[test can error when$1is empty. Quote$1(or use[[ ... ]]) to keep the gateway prompt selection robust.
subscripts/4Network/2Configure_networking.sh:167 - Same issue as above: unquoted
$1in a[test can error when$1is empty. Quote$1(or use[[ ... ]]) to keep the SSID default selection robust.
subscripts/4Network/2Configure_networking.sh:92 rm $FILENAMEwill print an error when the temp file doesn't exist (first run) and can also behave unexpectedly if$FILENAMEever contains whitespace. Preferrm -f -- "$FILENAME"to make this idempotent and safe.
subscripts/4Network/3Reenable_network_manager.sh:14- Masking and disabling
systemd-resolvedwhen re-enabling NetworkManager can break DNS resolution on Ubuntu (NetworkManager commonly integrates withsystemd-resolved). It's safer to only disable/masksystemd-networkd, and ensuresystemd-resolvedis unmasked/enabled.
subscripts/4Network/2Configure_networking.sh:149 if [ $1 = "f4f" ]will error with "unary operator expected" when the script is run without a first argument (common when invoked from a menu). Quote$1(or use[[ ... ]]) in these comparisons so empty args are handled safely.
subscripts/4Network/2Configure_networking.sh:157- Same issue as above: unquoted
$1in a[test can error when$1is empty. Quote$1(or use[[ ... ]]) to keep the gateway prompt selection robust.
subscripts/4Network/2Configure_networking.sh:167 - Same issue as above: unquoted
$1in a[test can error when$1is empty. Quote$1(or use[[ ... ]]) to keep the SSID default selection robust.
subscripts/4Network/2Configure_networking.sh:92 rm $FILENAMEwill print an error when the temp file doesn't exist (first run) and can also behave unexpectedly if$FILENAMEever contains whitespace. Preferrm -f -- "$FILENAME"to make this idempotent and safe.
subscripts/4Network/3Reenable_network_manager.sh:14- Masking and disabling
systemd-resolvedwhen re-enabling NetworkManager can break DNS resolution on Ubuntu (NetworkManager commonly integrates withsystemd-resolved). It's safer to only disable/masksystemd-networkd, and ensuresystemd-resolvedis unmasked/enabled.
subscripts/4Network/2Configure_networking.sh:149 if [ $1 = "f4f" ]will error with "unary operator expected" when the script is run without a first argument (common when invoked from a menu). Quote$1(or use[[ ... ]]) in these comparisons so empty args are handled safely.
subscripts/4Network/2Configure_networking.sh:157- Same issue as above: unquoted
$1in a[test can error when$1is empty. Quote$1(or use[[ ... ]]) to keep the gateway prompt selection robust.
subscripts/4Network/2Configure_networking.sh:167 - Same issue as above: unquoted
$1in a[test can error when$1is empty. Quote$1(or use[[ ... ]]) to keep the SSID default selection robust.
subscripts/4Network/2Configure_networking.sh:92 rm $FILENAMEwill print an error when the temp file doesn't exist (first run) and can also behave unexpectedly if$FILENAMEever contains whitespace. Preferrm -f -- "$FILENAME"to make this idempotent and safe.
subscripts/4Network/3Reenable_network_manager.sh:14- Masking and disabling
systemd-resolvedwhen re-enabling NetworkManager can break DNS resolution on Ubuntu (NetworkManager commonly integrates withsystemd-resolved). It's safer to only disable/masksystemd-networkd, and ensuresystemd-resolvedis unmasked/enabled.
subscripts/4Network/2Configure_networking.sh:86 sudo rm /etc/netplan/*will error when the directory is empty and can also delete non-YAML files if present. Prefer removing only*.yamlwith-fand silencing the empty-dir case.
subscripts/4Network/3Reenable_network_manager.sh:16sudo rm /etc/netplan/*will error when the directory is empty and can also delete non-YAML files if present. Prefer removing only*.yamlwith-fand silencing the empty-dir case.
subscripts/4Network/2Configure_networking.sh:86sudo rm /etc/netplan/*will error when the directory is empty and can also delete non-YAML files if present. Prefer removing only*.yamlwith-fand silencing the empty-dir case.
subscripts/4Network/3Reenable_network_manager.sh:16sudo rm /etc/netplan/*will error when the directory is empty and can also delete non-YAML files if present. Prefer removing only*.yamlwith-fand silencing the empty-dir case.
subscripts/4Network/2Configure_networking.sh:86sudo rm /etc/netplan/*will error when the directory is empty and can also delete non-YAML files if present. Prefer removing only*.yamlwith-fand silencing the empty-dir case.
subscripts/4Network/3Reenable_network_manager.sh:16sudo rm /etc/netplan/*will error when the directory is empty and can also delete non-YAML files if present. Prefer removing only*.yamlwith-fand silencing the empty-dir case.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Implemented some of the copilot suggestions and tested. Should work ok and can be merged |
gateway4 is deprecated
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
subscripts/4Network/3Reenable_network_manager.sh:26
- The temporary netplan file is written using unquoted
$FILENAMEand copied without quoting. Quoting the path and redirects avoids word-splitting/globbing and is safer if the location ever changes.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* 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
* Disable network manager immediately when configuring networking
* Install netplan if not installed yet
* Copilot fixes
* Migrate to newer default gateway syntax
gateway4 is deprecated
* Reformat
* Add default gateway prompt for eth
* Ensure netplan config file has correct permissions
* Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Ask for DNS server on eth
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Reformat * Check if git is already installed before installing * feat: Simplify networking (#6) * 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 * Disable network manager immediately when configuring networking * Install netplan if not installed yet * Copilot fixes * Migrate to newer default gateway syntax gateway4 is deprecated * Reformat * Add default gateway prompt for eth * Ensure netplan config file has correct permissions * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Ask for DNS server on eth --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * feat: Add script to clean home directory (#10) As written in the wiki. The script only deletes empty directories (to prevent accidentally deleting important files) * Use just one main entry script * Do not run apt update if it was already ran recently * Cleanup README.md --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Simplifies network configuration by removing the "Disable NetworkManager" step, which is now integrated directly into the netplan configuration step.
The PR also fixes some bugs when configuring IPs and only eth or only wifi interface is available