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
Expand Up @@ -7,5 +7,5 @@

if _val=$(getargs ip=); then
mkdir -p /run/agama/
: >/run/agama/copy_network
: >/run/agama/custom_dracut_network
fi
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ 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
# If there is some explicit network configuration provided through the ip= kernel cmdline option
# 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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np: do you need persistently here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could replace it by to /etc..

# 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
Expand All @@ -22,4 +22,6 @@ if [ -e /run/agama/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
6 changes: 6 additions & 0 deletions live/src/agama-installer.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Apr 28 16:40:41 UTC 2025 - Knut Anderssen <[email protected]>

- 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 <[email protected]>

Expand Down
4 changes: 2 additions & 2 deletions service/lib/agama/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"),
Expand Down
22 changes: 11 additions & 11 deletions service/test/agama/network_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down
Loading