Class: Yast::LinuxrcClass
- Inherits:
-
Module
- Object
- Module
- Yast::LinuxrcClass
- Includes:
- Logger
- Defined in:
- library/general/src/modules/Linuxrc.rb
Constant Summary collapse
- DISABLE_SNAPSHOTS =
Disables filesystem snapshots (fate#317973) Possible values: all, post, pre, single
"disable_snapshots".freeze
Instance Method Summary collapse
-
#braille ⇒ Object
braille mode ?.
-
#disable_remote(services) ⇒ Object
Reset settings for vnc, ssh,...
-
#display_ip ⇒ Object
remote X mode ?.
- #InstallInf(key) ⇒ Object
- #keys ⇒ Object
- #main ⇒ Object
-
#manual ⇒ Object
installation mode wrappers.
-
#ReadInstallInf ⇒ Object
routines for reading data from /etc/install.inf.
- #reboot_timeout ⇒ Object
- #ResetInstallInf ⇒ Object
-
#SaveInstallInf(root) ⇒ Object
Copy /etc/install.inf into built system so that the second phase of the installation can find it.
-
#serial_console ⇒ Object
running via serial console.
-
#text ⇒ Object
we're running in textmode (-> UI::GetDisplayInfo()).
-
#useiscsi ⇒ Object
Returns if iSCSI has been requested in Linuxrc.
-
#usessh ⇒ Object
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.
-
#value_for(feature_key) ⇒ String?
Returns value of a given Linxurc key/feature defined on commandline and written into install.inf.
-
#vnc ⇒ Object
vnc mode ?.
-
#WriteYaSTInf(linuxrc) ⇒ void
Write /etc/yast.inf during installation.
Instance Method Details
#braille ⇒ Object
braille mode ?
123 124 125 |
# File 'library/general/src/modules/Linuxrc.rb', line 123 def braille !InstallInf("Braille").nil? end |
#disable_remote(services) ⇒ Object
Reset settings for vnc, ssh,... in install.inf which have been made by linuxrc settings.
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'library/general/src/modules/Linuxrc.rb', line 264 def disable_remote(services) return if !services || services.empty? log.warn "Disabling #{services} due to missing packages." services.each do |service| # Service IDs are also used in another context in the code # Making sure we always compare apples with apples case polish(service.dup) when "vnc" SCR.Write(path(".etc.install_inf.VNC"), 0) SCR.Write(path(".etc.install_inf.VNCPassword"), "") when "ssh" SCR.Write(path(".etc.install_inf.UseSSH"), 0) when "braille" SCR.Write(path(".etc.install_inf.Braille"), 0) when "displayip" SCR.Write(path(".etc.install_inf.DISPLAY_IP"), 0) else log.error "Unknown service #{service}" raise ArgumentError, "Cannot disable #{service}: Unknown service." end end SCR.Write(path(".etc.install_inf"), nil) # Flush the cache ResetInstallInf() end |
#display_ip ⇒ Object
remote X mode ?
133 134 135 |
# File 'library/general/src/modules/Linuxrc.rb', line 133 def display_ip !InstallInf("Display_IP").nil? end |
#InstallInf(key) ⇒ Object
89 90 91 92 |
# File 'library/general/src/modules/Linuxrc.rb', line 89 def InstallInf(key) ReadInstallInf() @install_inf[key] end |
#keys ⇒ Object
94 95 96 97 |
# File 'library/general/src/modules/Linuxrc.rb', line 94 def keys ReadInstallInf() @install_inf.keys end |
#main ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'library/general/src/modules/Linuxrc.rb', line 38 def main Yast.import "Mode" Yast.import "Stage" @install_inf = nil @_manual = nil end |
#manual ⇒ Object
installation mode wrappers
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'library/general/src/modules/Linuxrc.rb', line 101 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 |
#ReadInstallInf ⇒ Object
routines for reading data from /etc/install.inf
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 74 75 76 77 78 79 80 81 82 |
# File 'library/general/src/modules/Linuxrc.rb', line 49 def ReadInstallInf return if !@install_inf.nil? # skip from chroot old_SCR = WFM.SCRGetDefault new_SCR = WFM.SCROpen("chroot=/:scr", false) WFM.SCRSetDefault(new_SCR) begin @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 ensure # close and chroot back WFM.SCRSetDefault(old_SCR) WFM.SCRClose(new_SCR) end nil end |
#reboot_timeout ⇒ Object
155 156 157 158 159 |
# File 'library/general/src/modules/Linuxrc.rb', line 155 def reboot_timeout return nil unless InstallInf("reboot_timeout") InstallInf("reboot_timeout").to_i end |
#ResetInstallInf ⇒ Object
84 85 86 87 |
# File 'library/general/src/modules/Linuxrc.rb', line 84 def ResetInstallInf @install_inf = nil nil end |
#SaveInstallInf(root) ⇒ Object
Copy /etc/install.inf into built system so that the second phase of the installation can find it.
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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'library/general/src/modules/Linuxrc.rb', line 185 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.y2error( "Can't SaveInstallInf, file %1 doesn't exist", inst_if_file ) else 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 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 |
#serial_console ⇒ Object
running via serial console
118 119 120 |
# File 'library/general/src/modules/Linuxrc.rb', line 118 def serial_console !InstallInf("Console").nil? end |
#text ⇒ Object
we're running in textmode (-> UI::GetDisplayInfo())
151 152 153 |
# File 'library/general/src/modules/Linuxrc.rb', line 151 def text InstallInf("Textmode") == "1" end |
#useiscsi ⇒ Object
Returns if iSCSI has been requested in Linuxrc.
146 147 148 |
# File 'library/general/src/modules/Linuxrc.rb', line 146 def useiscsi InstallInf("WithiSCSI") == "1" end |
#usessh ⇒ Object
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
141 142 143 |
# File 'library/general/src/modules/Linuxrc.rb', line 141 def usessh InstallInf("UseSSH") == "1" end |
#value_for(feature_key) ⇒ String?
Returns value of a given Linxurc key/feature defined on commandline and written into install.inf
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'library/general/src/modules/Linuxrc.rb', line 242 def value_for(feature_key) ReadInstallInf() feature_key = polish(feature_key) # at first check the keys in install.inf install_inf_key, install_inf_val = @install_inf.find { |k, _v| polish(k) == feature_key } return install_inf_val if install_inf_key # then check the command line ret = nil @install_inf.fetch("Cmdline", "").split.each do |cmdline_entry| key, val = cmdline_entry.split("=", 2) ret = val if polish(key) == feature_key end ret end |
#vnc ⇒ Object
vnc mode ?
128 129 130 |
# File 'library/general/src/modules/Linuxrc.rb', line 128 def vnc InstallInf("VNC") == "1" end |
#WriteYaSTInf(linuxrc) ⇒ void
This method returns an undefined value.
Write /etc/yast.inf during installation
166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'library/general/src/modules/Linuxrc.rb', line 166 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 |