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
20 changes: 20 additions & 0 deletions service/lib/agama/storage/finisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,30 @@ def label
end

def run
run_post_scripts
enable_init_scripts
end

private

# Run the post scripts
def run_post_scripts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not related to this PR, but I think all these things about scripts are misplaced in a storage finisher.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, there are quite some things that do not belong here. We will find better places as we continue moving stuff to Rust.

require "agama/http"
client = Agama::HTTP::Clients::Scripts.new
client.run("post")
end

# Enables the agama-scripts service to run init scripts
#
# The package agama-scripts is only installed when needed.
# So this method just tries to enable the service.
def enable_init_scripts
# systemctl will return 1 if the service does not exist.
Yast::Execute.on_target!(
"systemctl", "enable", "agama-scripts",
allowed_exitstatus: [0, 1]
)
end
end

# Step to unmount the target file-systems
Expand Down
5 changes: 5 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Feb 25 23:48:46 UTC 2025 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Enable agama-scripts service if installed (gh#agama-project/agama#2077).

-------------------------------------------------------------------
Mon Feb 24 12:03:58 UTC 2025 - Ladislav Slezák <lslezak@suse.com>

Expand Down
3 changes: 3 additions & 0 deletions service/test/agama/storage/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
allow(File).to receive(:directory?).and_call_original
allow(File).to receive(:directory?).with("/iguana").and_return iguana
allow(copy_files_class).to receive(:new).and_return(copy_files)
allow(Yast::Execute).to receive(:on_target!)
end
let(:copy_files_class) { Agama::Storage::Finisher::CopyFilesStep }
let(:copy_files) { instance_double(copy_files_class, run?: true, run: true, label: "Copy") }
Expand All @@ -375,6 +376,8 @@
expect(Yast::WFM).to receive(:CallFunction).with("storage_finish", ["Write"])
expect(Yast::WFM).to receive(:CallFunction).with("snapshots_finish", ["Write"])
expect(scripts_client).to receive(:run).with("post")
expect(Yast::Execute).to receive(:on_target!)
.with("systemctl", "enable", "agama-scripts", allowed_exitstatus: [0, 1])
expect(Yast::WFM).to receive(:CallFunction).with("copy_logs_finish", ["Write"])
expect(Yast::WFM).to receive(:CallFunction).with("umount_finish", ["Write"])
storage.finish
Expand Down