Class: Yast::FirstbootClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/Firstboot.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) ExecuteScripts

Execute custom scripts

Returns:

  • boolean



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File '../../src/modules/Firstboot.rb', line 117

def ExecuteScripts
  @script_dir = Misc.SysconfigRead(
    path(".sysconfig.firstboot.SCRIPT_DIR"),
    "/usr/share/firstboot/scripts"
  )

  if @script_dir != ""
    scripts = Builtins.sort(
      Convert.convert(
        SCR.Read(path(".target.dir"), @script_dir),
        :from => "any",
        :to   => "list <string>"
      )
    )
    Builtins.foreach(scripts) do |script|
      ret = Convert.to_map(
        SCR.Execute(
          path(".target.bash_output"),
          Ops.add(
            Ops.add(Ops.add(@script_dir, "/"), script),
            " >> /var/log/YaST2/firstboot.log"
          )
        )
      )
      if Ops.get_integer(ret, "exit", -1) != 0
        Builtins.y2error("script failed: %1", ret)
      end
    end
  else
    Builtins.y2error("Script dir empty or not configured")
  end
  true
end

- (Object) Export

Export firstboot settigs defined by autoyast



163
164
165
# File '../../src/modules/Firstboot.rb', line 163

def Export
  { "firstboot_enabled" => @firstboot_enabled }
end

- (Object) Firstboot



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File '../../src/modules/Firstboot.rb', line 75

def Firstboot
  if Mode.config || Mode.autoinst
    Builtins.y2milestone(
      "no firstboot initialization in mode %1",
      Mode.mode
    )
    return
  end
  @show_y2cc_checkbox = Misc.SysconfigRead(
    path(".sysconfig.firstboot.SHOW_Y2CC_CHECKBOX"),
    "no"
  ) == "yes"
  @default_wm = Misc.SysconfigRead(
    path(".sysconfig.windowmanager.DEFAULT_WM"),
    "kde"
  )
  Progress.off
  NetworkInterfaces.Read
  Progress.on
  Internet.do_you = true

  control_file = Misc.SysconfigRead(
    path(".sysconfig.firstboot.FIRSTBOOT_CONTROL_FILE"),
    ""
  )
  @firstboot_control_file = control_file if control_file != ""

  ProductControl.custom_control_file = @firstboot_control_file

  if !ProductControl.Init
    Builtins.y2error(
      "control file %1 not found",
      ProductControl.custom_control_file
    )
  end

  nil
end

- (Object) Import(settings)

Import firstboot settigs defined by autoyast



152
153
154
155
156
157
158
159
160
# File '../../src/modules/Firstboot.rb', line 152

def Import(settings)
  settings = deep_copy(settings)
  ena = Ops.get_boolean(settings, "firstboot_enabled", @firstboot_enabled)
  if ena != @firstboot_enabled
    @firstboot_enabled = ena
    @modified = true
  end
  @modified
end

- (Object) main



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File '../../src/modules/Firstboot.rb', line 35

def main
  textdomain "firstboot"

  Yast.import "NetworkInterfaces"
  Yast.import "Progress"
  Yast.import "Internet"
  Yast.import "Misc"
  Yast.import "Mode"
  Yast.import "Directory"
  Yast.import "ProductControl"
  Yast.import "Summary"



  @script_dir = ""

  @no_text = _("No Text Available")

  @show_y2cc_checkbox = false

  @language_changed = false

  # definition of firstboot sequence (and the default path)
  @firstboot_control_file = "/etc/YaST2/firstboot.xml"

  # file triggering start of firstboot sequence
  @reconfig_file = "/var/lib/YaST2/reconfig_system"

  @default_wm = ""

  @installed_desktops = []

  # for autoinstallation: should the firstboot be enbaled?
  @firstboot_enabled = false

  # if some settings were modified (currently for autoyast only)
  @modified = false
  Firstboot()
end

- (Object) Summary

Summary() returns html formated configuration summary

Returns:

  • summary



169
170
171
172
173
174
175
176
177
178
# File '../../src/modules/Firstboot.rb', line 169

def Summary
  summary =
    # summary item
    Summary.AddHeader("", _("Firstboot configuration disabled"))
  if @firstboot_enabled
    # summary item
    summary = Summary.AddHeader("", _("Firstboot configuration enabled"))
  end
  summary
end

- (Object) Write

Write firstboot settings



182
183
184
185
186
187
188
189
190
191
192
# File '../../src/modules/Firstboot.rb', line 182

def Write
  if @firstboot_enabled
    Builtins.y2milestone("enabling firstboot...")
    SCR.Execute(
      path(".target.bash"),
      Ops.add("/bin/touch ", @reconfig_file)
    )
  end

  nil
end