Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

[ -e /dracut-state.sh ] && . /dracut-state.sh

. /lib/dracut-lib.sh
. /lib/net-lib.sh

if _val=$(getargs ip=); then
mkdir -p /run/agama/
: >/run/agama/copy_network
fi
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ installkernel() {
install() {
inst_hook cmdline 99 "$moddir/agama-cmdline-conf.sh"
inst_hook cmdline 99 "$moddir/agama-network-compat.sh"
inst_hook cmdline 99 "$moddir/agama-network.sh"
inst_hook pre-pivot 99 "$moddir/save-agama-conf.sh"
}
16 changes: 16 additions & 0 deletions live/live-root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@
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
mkdir -p /run/NetworkManager/conf.d
echo '[main]' >/run/NetworkManager/conf.d/00-agama-server.conf
Comment thread
teclator marked this conversation as resolved.
echo 'no-auto-default=*' >>/run/NetworkManager/conf.d/00-agama-server.conf
echo 'ignore-carrier=*' >>/run/NetworkManager/conf.d/00-agama-server.conf

mkdir -p "$NEWROOT/etc/NetworkManager/system-connections/"
cp /run/NetworkManager/system-connections/* "$NEWROOT/etc/NetworkManager/system-connections/"
fi
fi
12 changes: 12 additions & 0 deletions live/src/agama-installer.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
-------------------------------------------------------------------
Thu Apr 24 16:40:41 UTC 2025 - Knut Anderssen <kanderssen@suse.com>

- bsc#1239777, bsc#1236885 gh#agama-project/agama#2291.
- Persist the NetworkManager runtime config created by
nm-initrd-generator when given explicitlly with the 'ip='
kernel cmdline argument.
- Allow to disable the copy of the persistent configuration with
the inst.copy_network kernel cmdline argument.
- Do not copy the NetworkManager runtime configuration to the
target system anymore.

-------------------------------------------------------------------
Thu Apr 24 15:11:35 UTC 2025 - Ladislav Slezák <lslezak@suse.com>

Expand Down
9 changes: 2 additions & 7 deletions service/lib/agama/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def unlink_resolv

HOSTNAME = "/etc/hostname"
RESOLV = "/etc/resolv.conf"
COPY_NETWORK = "/run/agama/copy_network"
RESOLV_FLAG = "/run/agama/manage_resolv"
ETC_NM_DIR = "/etc/NetworkManager"
RUN_NM_DIR = "/run/NetworkManager"
Expand All @@ -93,13 +94,7 @@ def copy_files
copy(HOSTNAME)

return unless Dir.exist?(ETC_NM_DIR)

# runtime configuration is copied first, so in case of later modification
# on same interface it gets overwriten (bsc#1210541).
copy_directory(
File.join(RUN_NM_DIR, "system-connections"),
File.join(Yast::Installation.destdir, ETC_NM_DIR, "system-connections")
)
return unless File.exist?(COPY_NETWORK)

copy_directory(
File.join(ETC_NM_DIR, "system-connections"),
Expand Down
7 changes: 7 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Apr 24 17:18:04 UTC 2025 - Knut Anderssen <kanderssen@suse.com>

- Copy only the NetworkManager connnections from /etc and just
in case the copy has not been disabled
(gh#agama-project/agama#2291).

-------------------------------------------------------------------
Thu Apr 24 14:10:46 UTC 2025 - Josef Reidinger <jreidinger@suse.com>

Expand Down
31 changes: 26 additions & 5 deletions service/test/agama/network_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
let(:targetdir) { File.join(rootdir, "mnt") }
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") }

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)
FileUtils.mkdir_p(agama_dir)
end

after do
Expand All @@ -48,6 +52,7 @@
let(:etcdir) do
File.join(rootdir, "etc", "NetworkManager", "system-connections")
end

let(:service) { instance_double(Yast2::Systemd::Service, enable: nil) }

before do
Expand All @@ -61,11 +66,27 @@
FileUtils.touch(File.join(etcdir, "system-connections", "wired.nmconnection"))
end

it "copies the configuration files" do
network.install
expect(File).to exist(
File.join(targetdir, etcdir, "system-connections", "wired.nmconnection")
)
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

it "copies the configuration files" do
network.install
expect(File).to exist(
File.join(targetdir, etcdir, "system-connections", "wired.nmconnection")
)
end
end

context "and the /run/agama/copy_network file does not exist" do
it "does not try to copy any file" do
expect(FileUtils).to_not receive(:cp_r)
network.install
end
end
end

Expand Down
Loading