Skip to content

Commit

Permalink
Run pre-scripts just after the profile has been processed
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jul 3, 2020
1 parent 44a79e8 commit 615596f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
20 changes: 0 additions & 20 deletions src/clients/inst_autosetup.rb
Expand Up @@ -69,7 +69,6 @@ def main
"<P>Please wait while the system is prepared for autoinstallation.</P>"
)
@progress_stages = [
_("Execute pre-install user scripts"),
_("Configure General Settings "),
_("Set up language"),
_("Configure security settings"),
Expand All @@ -84,7 +83,6 @@ def main
]

@progress_descriptions = [
_("Executing pre-install user scripts..."),
_("Configuring general settings..."),
_("Setting up language..."),
_("Configuring security settings"),
Expand Down Expand Up @@ -127,24 +125,6 @@ def main
# Partitioning and Storage
# //////////////////////////////////////////////////////////////////////

@modified = true
begin
askDialog
# Pre-Scripts
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
AutoinstScripts.Write("pre-scripts", false)
@ret2 = readModified
return :abort if @ret2 == :abort

@modified = false if @ret2 == :not_found
if Ops.greater_or_equal(
SCR.Read(path(".target.size"), "/var/lib/YaST2/restart_yast"),
0
)
return :restart_yast
end
end while @modified == true

# reimport scripts, for the case <ask> has changed them
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
#
Expand Down
28 changes: 27 additions & 1 deletion src/lib/autoinstall/clients/inst_autoinit.rb
Expand Up @@ -6,6 +6,7 @@
Yast.import "AutoinstConfig"
Yast.import "AutoinstFunctions"
Yast.import "AutoinstGeneral"
Yast.import "AutoinstScripts"
Yast.import "Call"
Yast.import "Console"
Yast.import "InstURL"
Expand All @@ -24,6 +25,7 @@
module Y2Autoinstallation
module Clients
class InstAutoinit
include Yast
include Y2Autoinstallation::AutosetupHelpers
include Yast::Logger
include Yast::UIShortcuts
Expand All @@ -36,6 +38,8 @@ def self.run

def initialize
textdomain "autoinst"

Yast.include self, "autoinstall/ask.rb"
end

def run
Expand All @@ -48,7 +52,8 @@ def run
_("Probe hardware"),
_("Retrieve & Read Control File"),
_("Parse control file"),
_("Initial Configuration")
_("Initial Configuration"),
_("Execute pre-install user scripts")
]

Yast::Progress.New(
Expand All @@ -74,6 +79,12 @@ def run
ret = processProfile
return ret if ret != :ok

Yast::Progress.NextStep
Yast::Progress.Title(_("Executing pre-install user scripts..."))
log.info("Executing pre-scripts")

autoinit_scripts

Yast::Progress.Finish

# when installing from the online installation medium we need to
Expand Down Expand Up @@ -132,6 +143,21 @@ def run

private

def autoinit_scripts
@modified = true
loop do
askDialog
# Pre-Scripts
Yast::AutoinstScripts.Import(Yast::Profile.current["scripts"] || {})
Yast::AutoinstScripts.Write("pre-scripts", false)
ret = readModified
return :abort if ret == :abort

return :restart_yast if File.exist?("/var/lib/YaST2/restart_yast")
break if ret == :not_found
end
end

# Checking profile for unsupported sections.
def check_unsupported_profile_sections
unsupported_sections = Yast::Y2ModuleConfig.unsupported_profile_sections
Expand Down

0 comments on commit 615596f

Please sign in to comment.