From c5942674471b8d6f3e15705ac385121601d8cc01 Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Mon, 28 Apr 2025 12:35:27 +0100 Subject: [PATCH 1/3] Create always /run/agama/copy_network if not disabled --- .../modules.d/99agama-cmdline/agama-network.sh | 2 +- .../modules.d/99agama-cmdline/save-agama-conf.sh | 13 +++++++------ live/src/agama-installer.changes | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/agama-network.sh b/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/agama-network.sh index 46712b9e3f..8b91900aff 100755 --- a/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/agama-network.sh +++ b/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/agama-network.sh @@ -7,5 +7,5 @@ if _val=$(getargs ip=); then mkdir -p /run/agama/ - : >/run/agama/copy_network + : >/run/agama/custom_dracut_network fi diff --git a/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh b/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh index 1df6d90b03..becb3a5fb7 100755 --- a/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh +++ b/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh @@ -8,12 +8,13 @@ if [ -e /etc/hostname ]; then cp /etc/hostname "$NEWROOT/etc/hostname" fi -# If there is some explicit network configuration provided through the ip= kernel cmdline option -# then we set the config server configuration diabling the DHCP auto configuration for ethernet -# devices and also copying the configuration persistently (bsc#1241224, bsc#122486, bsc#1239777, -# bsc#1236885). -if [ -e /run/agama/copy_network ]; then - if getargbool 1 inst.copy_network; then +if getargbool 1 inst.copy_network; then + : >/run/agama/copy_network + # If there is some explicit network configuration provided through the ip= kernel cmdline option + # then we set the config server configuration diabling the DHCP auto configuration for ethernet + # devices and also copying the configuration persistently (bsc#1241224, bsc#122486, bsc#1239777, + # bsc#1236885). + if [ -e /run/agama/custom_dracut_network ]; then mkdir -p /run/NetworkManager/conf.d echo '[main]' >/run/NetworkManager/conf.d/00-agama-server.conf echo 'no-auto-default=*' >>/run/NetworkManager/conf.d/00-agama-server.conf diff --git a/live/src/agama-installer.changes b/live/src/agama-installer.changes index 2847bfee88..71935335c3 100644 --- a/live/src/agama-installer.changes +++ b/live/src/agama-installer.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 28 16:40:41 UTC 2025 - Knut Anderssen + +- Always create the /run/agama/copy_network file if not explicitly + disabled (related to gh#agama-project/agama#2291). + ------------------------------------------------------------------- Mon Apr 28 12:14:51 UTC 2025 - Ladislav Slezák From 4f821d7d85d6142bca7aef81d7936017552da4ce Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Mon, 28 Apr 2025 13:02:10 +0100 Subject: [PATCH 2/3] Modify copy_network flag to not_copy_network --- .../99agama-cmdline/save-agama-conf.sh | 3 ++- live/src/agama-installer.changes | 4 ++-- service/lib/agama/network.rb | 4 ++-- service/test/agama/network_test.rb | 22 +++++++++---------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh b/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh index becb3a5fb7..e6bcf1a3ef 100755 --- a/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh +++ b/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh @@ -9,7 +9,6 @@ if [ -e /etc/hostname ]; then fi if getargbool 1 inst.copy_network; then - : >/run/agama/copy_network # If there is some explicit network configuration provided through the ip= kernel cmdline option # then we set the config server configuration diabling the DHCP auto configuration for ethernet # devices and also copying the configuration persistently (bsc#1241224, bsc#122486, bsc#1239777, @@ -23,4 +22,6 @@ if getargbool 1 inst.copy_network; then mkdir -p "$NEWROOT/etc/NetworkManager/system-connections/" cp /run/NetworkManager/system-connections/* "$NEWROOT/etc/NetworkManager/system-connections/" fi +else + : >/run/agama/not_copy_network fi diff --git a/live/src/agama-installer.changes b/live/src/agama-installer.changes index 71935335c3..bf1dae1502 100644 --- a/live/src/agama-installer.changes +++ b/live/src/agama-installer.changes @@ -1,8 +1,8 @@ ------------------------------------------------------------------- Thu Apr 28 16:40:41 UTC 2025 - Knut Anderssen -- Always create the /run/agama/copy_network file if not explicitly - disabled (related to gh#agama-project/agama#2291). +- Ensure the persistent NetworkManager connections are copied if + not explicitlly disabled (related to gh#agama-project/agama#2291) ------------------------------------------------------------------- Mon Apr 28 12:14:51 UTC 2025 - Ladislav Slezák diff --git a/service/lib/agama/network.rb b/service/lib/agama/network.rb index cc736f80e5..77738f7755 100644 --- a/service/lib/agama/network.rb +++ b/service/lib/agama/network.rb @@ -73,7 +73,7 @@ def unlink_resolv HOSTNAME = "/etc/hostname" RESOLV = "/etc/resolv.conf" - COPY_NETWORK = "/run/agama/copy_network" + NOT_COPY_NETWORK = "/run/agama/not_copy_network" RESOLV_FLAG = "/run/agama/manage_resolv" ETC_NM_DIR = "/etc/NetworkManager" RUN_NM_DIR = "/run/NetworkManager" @@ -94,7 +94,7 @@ def copy_files copy(HOSTNAME) return unless Dir.exist?(ETC_NM_DIR) - return unless File.exist?(COPY_NETWORK) + return if File.exist?(NOT_COPY_NETWORK) copy_directory( File.join(ETC_NM_DIR, "system-connections"), diff --git a/service/test/agama/network_test.rb b/service/test/agama/network_test.rb index 79a0158d52..cf1928aa36 100644 --- a/service/test/agama/network_test.rb +++ b/service/test/agama/network_test.rb @@ -32,13 +32,13 @@ let(:fixtures) { File.join(FIXTURES_PATH, "root_dir") } let(:hostname_path) { File.join(fixtures, "etc", "hostname") } let(:agama_dir) { File.join(rootdir, "run", "agama") } - let(:copy_network) { File.join(agama_dir, "copy_network") } + let(:not_copy_network) { File.join(agama_dir, "not_copy_network") } before do allow(Yast::Installation).to receive(:destdir).and_return(targetdir) stub_const("Agama::Network::HOSTNAME", hostname_path) stub_const("Agama::Network::RUN_NM_DIR", File.join(rootdir, "run", "NetworkManager")) - stub_const("Agama::Network::COPY_NETWORK", copy_network) + stub_const("Agama::Network::NOT_COPY_NETWORK", not_copy_network) FileUtils.mkdir_p(agama_dir) end @@ -66,14 +66,7 @@ FileUtils.touch(File.join(etcdir, "system-connections", "wired.nmconnection")) end - context "and the /run/agama/copy_network file exists" do - around do |block| - FileUtils.mkdir_p(agama_dir) - FileUtils.touch(copy_network) - block.call - FileUtils.rm_f(copy_network) - end - + context "and the /run/agama/not_copy_network file does not exist" do it "copies the configuration files" do network.install expect(File).to exist( @@ -82,7 +75,14 @@ end end - context "and the /run/agama/copy_network file does not exist" do + context "and the /run/agama/not_copy_network file exists" do + around do |block| + FileUtils.mkdir_p(agama_dir) + FileUtils.touch(not_copy_network) + block.call + FileUtils.rm_f(not_copy_network) + end + it "does not try to copy any file" do expect(FileUtils).to_not receive(:cp_r) network.install From 94bc4a32885a805001fcc2315613c53341051f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Tue, 29 Apr 2025 10:56:19 +0100 Subject: [PATCH 3/3] Update live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Imobach González Sosa --- .../usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh b/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh index e6bcf1a3ef..3188b02ba0 100755 --- a/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh +++ b/live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh @@ -10,7 +10,7 @@ fi if getargbool 1 inst.copy_network; then # If there is some explicit network configuration provided through the ip= kernel cmdline option - # then we set the config server configuration diabling the DHCP auto configuration for ethernet + # then we set the config server configuration disabling the DHCP auto configuration for ethernet # devices and also copying the configuration persistently (bsc#1241224, bsc#122486, bsc#1239777, # bsc#1236885). if [ -e /run/agama/custom_dracut_network ]; then