Class: Yast::LinuxrcClass

Inherits:
Module
  • Object
show all
Defined in:
../../library/general/src/modules/Linuxrc.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) braille

braille mode ?



107
108
109
# File '../../library/general/src/modules/Linuxrc.rb', line 107

def braille
  InstallInf("Braille") != nil
end

- (Object) display_ip

remote X mode ?



116
117
118
# File '../../library/general/src/modules/Linuxrc.rb', line 116

def display_ip
  InstallInf("Display_IP") != nil
end

- (Object) InstallInf(key)



74
75
76
77
# File '../../library/general/src/modules/Linuxrc.rb', line 74

def InstallInf(key)
  ReadInstallInf()
  @install_inf[key]
end

- (Object) keys



79
80
81
82
# File '../../library/general/src/modules/Linuxrc.rb', line 79

def keys
  ReadInstallInf()
  @install_inf.keys
end

- (Object) main



34
35
36
37
38
39
40
41
# File '../../library/general/src/modules/Linuxrc.rb', line 34

def main
  Yast.import "Mode"
  Yast.import "Stage"

  @install_inf = nil

  @_manual = nil
end

- (Object) manual

installation mode wrappers



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File '../../library/general/src/modules/Linuxrc.rb', line 86

def manual
  return @_manual if @_manual != nil
  @_manual = InstallInf("Manual") == "1"
  if !@_manual
    tmp = Convert.to_string(
      SCR.Read(path(".target.string"), "/proc/cmdline")
    )
    if tmp != nil &&
        Builtins.contains(Builtins.splitstring(tmp, " \n"), "manual")
      @_manual = true
    end
  end
  @_manual
end

- (Object) ReadInstallInf

routines for reading data from /etc/install.inf



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File '../../library/general/src/modules/Linuxrc.rb', line 45

def ReadInstallInf
  return if @install_inf != nil

  @install_inf = {}
  # don't read anything if the file doesn't exist
  if SCR.Read(path(".target.size"), "/etc/install.inf") == -1
    Builtins.y2error("Reading install.inf, but file doesn't exist!!!")
    return
  end
  entries = SCR.Dir(path(".etc.install_inf"))
  if entries == nil
    Builtins.y2error("install.inf is empty")
    return
  end
  Builtins.foreach(entries) do |e|
    val = Convert.to_string(
      SCR.Read(Builtins.add(path(".etc.install_inf"), e))
    )
    Ops.set(@install_inf, e, val)
  end

  nil
end

- (Object) ResetInstallInf



69
70
71
72
# File '../../library/general/src/modules/Linuxrc.rb', line 69

def ResetInstallInf
  @install_inf = nil
  nil
end

- (Object) SaveInstallInf(root)

Copy /etc/install.inf into built system so that the second phase of the installation can find it.

Parameters:

  • root

    mount point of system

Returns:

  • boolean true on success



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File '../../library/general/src/modules/Linuxrc.rb', line 162

def SaveInstallInf(root)
  if Stage.initial && !Mode.test
    inst_if_file = "/etc/install.inf"

    if root != nil && root != "" && root != "/"
      if WFM.Read(path(".local.size"), inst_if_file) != -1
        Builtins.y2milestone("Copying %1 to %2", inst_if_file, root)
        if Convert.to_integer(
            WFM.Execute(
              path(".local.bash"),
              Builtins.sformat(
                "grep -vi '^Sourcemounted' '%1' > %2/%1; chmod 0600 %2/%1",
                inst_if_file,
                root
              )
            )
          ) != 0
          Builtins.y2error(
            "Cannot SaveInstallInf %1 to %2",
            inst_if_file,
            root
          )
        end
      else
        Builtins.y2error(
          "Can't SaveInstallInf, file %1 doesn't exist",
          inst_if_file
        )
      end
    else
      Builtins.y2error("Can't SaveInstallInf, root is %1", root)
    end

    # just for debug so we can see the original install.inf later
    SCR.Execute(
      path(".target.bash"),
      Ops.add(
        Ops.add("/bin/cp /etc/install.inf ", root),
        "/var/lib/YaST2/install.inf"
      )
    )
    SCR.Execute(
      path(".target.bash"),
      Ops.add(
        Ops.add("/bin/chmod 0600 ", root),
        "/var/lib/YaST2/install.inf"
      )
    )
  end
  true
end

- (Object) serial_console

running via serial console



102
103
104
# File '../../library/general/src/modules/Linuxrc.rb', line 102

def serial_console
  InstallInf("Console") != nil
end

- (Object) text

we're running in textmode (-> UI::GetDisplayInfo())



134
135
136
# File '../../library/general/src/modules/Linuxrc.rb', line 134

def text
  InstallInf("Textmode") == "1"
end

- (Object) useiscsi

Returns if iSCSI has been requested in Linuxrc.



129
130
131
# File '../../library/general/src/modules/Linuxrc.rb', line 129

def useiscsi
  InstallInf("WithiSCSI") == "1"
end

- (Object) usessh

ssh mode ? if booted with 'vnc=1 usessh=1', keep vnc mode, but start sshd if booted with 'display_ip=1.2.3.4 usessh=1', keep remote X mode, but start sshd this has to be checked by the caller, not here



124
125
126
# File '../../library/general/src/modules/Linuxrc.rb', line 124

def usessh
  InstallInf("UseSSH") == "1"
end

- (Object) vnc

vnc mode ?



112
113
114
# File '../../library/general/src/modules/Linuxrc.rb', line 112

def vnc
  InstallInf("VNC") == "1"
end

- (void) WriteYaSTInf(linuxrc)

This method returns an undefined value.

Write /etc/yast.inf during installation

Parameters:

  • linuxrc (Hash{String => String})

    map of key value pairs for /etc/yast.inf



143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File '../../library/general/src/modules/Linuxrc.rb', line 143

def WriteYaSTInf(linuxrc)
  linuxrc = deep_copy(linuxrc)
  yast_inf = ""
  Builtins.foreach(linuxrc) do |ykey, yvalue|
    yast_inf = Ops.add(
      Ops.add(Ops.add(Ops.add(yast_inf, ykey), ": "), yvalue),
      "\n"
    )
  end
  Builtins.y2milestone("WriteYaSTInf(%1) = %2", linuxrc, yast_inf)

  WFM.Write(path(".local.string"), "/etc/yast.inf", yast_inf) if !Mode.test
  nil
end