Class: Yast::NfsClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Hash) AutoPackages

Return required packages for auto-installation

Returns:

  • (Hash)

    of packages to be installed and to be removed



697
698
699
# File '../../src/modules/Nfs.rb', line 697

def AutoPackages
  { "install" => @required_packages, "remove" => [] }
end

- (Object) EscapeSpaces(entries)

Escape spaces “ ” -> “040” in all values of all entries

Parameters:

  • entries (Array<Hash{String => Object>})

    a list of maps, such as nfs_entries

Returns:

  • escaped entries



273
274
275
276
277
278
279
280
281
282
# File '../../src/modules/Nfs.rb', line 273

def EscapeSpaces(entries)
  entries = deep_copy(entries)
  Builtins.maplist(entries) { |entry| Builtins.mapmap(entry) do |key, value|
    {
      key => Ops.is_string?(value) ?
        EscapeSpaces1(Convert.to_string(value)) :
        value
    }
  end }
end

- (Object) EscapeSpaces1(s)

Escape spaces “ ” -> “040”.

Parameters:

  • s (String)

    a string or nil

Returns:

  • escaped string or nil



264
265
266
267
268
# File '../../src/modules/Nfs.rb', line 264

def EscapeSpaces1(s)
  s == nil ?
    nil :
    Builtins.mergestring(Builtins.splitstring(s, " "), "\\040")
end

- (Object) Export

Dump the NFS settings to a map, for autoinstallation use.

Returns:

  • a list of nfs entries.



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File '../../src/modules/Nfs.rb', line 238

def Export
  settings = {}

  Ops.set(settings, "enable_nfs4", @nfs4_enabled)
  Ops.set(settings, "enable_nfs_gss", @nfs_gss_enabled)
  Ops.set(settings, "idmapd_domain", @idmapd_domain)

  entries = Builtins.maplist(@nfs_entries) do |entry|
    {
      "server_path" => Ops.get_string(entry, "spec", ""),
      "mount_point" => Ops.get_string(entry, "file", ""),
      "vfstype"     => Ops.get_string(entry, "vfstype", ""),
      "nfs_options" => Ops.get_string(entry, "mntops", "")
    }
  end
  Ops.set(settings, "nfs_entries", entries)
  deep_copy(settings)
end

- (Object) FillEntriesDefaults(entries)

Fill in the defaults for AY profile entries.



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

def FillEntriesDefaults(entries)
  entries = deep_copy(entries)
  Builtins.maplist(entries) do |e|
    #Backwards compatibility: with FaTE#302031, we support nfsv4 mounts
    #thus we need to keep info on nfs version (v3 vs. v4)
    #But older AY profiles might not contain this element
    #so let's assume nfsv3 in that case (#395850)
    Ops.set(e, "vfstype", "nfs") if !Builtins.haskey(e, "vfstype")
    deep_copy(e)
  end
end

- (Object) FindPortmapper



329
330
331
332
333
334
# File '../../src/modules/Nfs.rb', line 329

def FindPortmapper
  #testsuite is dumb - it can't distinguish between the existence
  #of two services - either both exists or both do not
  return "portmap" if Mode.testsuite
  Service.Find(["rpcbind", "portmap"])
end

- (Boolean) GetModified

Functions which returns if the settings were modified

Returns:

  • (Boolean)

    settings were modified



79
80
81
# File '../../src/modules/Nfs.rb', line 79

def GetModified
  @modified
end

- (Object) GetOptionsAndEntries(any_settings, global_options, entries)

From settings (which is a list in SLE11 but a map in oS: bnc#820989), extract the options and the NFS fstab entries.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File '../../src/modules/Nfs.rb', line 135

def GetOptionsAndEntries(any_settings, global_options, entries)
  any_settings = deep_copy(any_settings)
  # map: oS;
  if Ops.is_map?(any_settings)
    global_options_ref = arg_ref(global_options.value)
    entries_ref = arg_ref(entries.value)
    GetOptionsAndEntriesMap(
      Convert.to_map(any_settings),
      global_options_ref,
      entries_ref
    )
    global_options.value = global_options_ref.value
    entries.value = entries_ref.value
  elsif Ops.is(any_settings, "list <map>")
    global_options_ref = arg_ref(global_options.value)
    entries_ref = arg_ref(entries.value)
    GetOptionsAndEntriesSLE11(
      Convert.convert(any_settings, :from => "any", :to => "list <map>"),
      global_options_ref,
      entries_ref
    )
    global_options.value = global_options_ref.value
    entries.value = entries_ref.value
  else
    Builtins.y2internal(
      "Cannot happen, got neither a map nor a list: %1",
      any_settings
    )
  end

  nil
end

- (Object) GetOptionsAndEntriesMap(settings, global_options, entries)



125
126
127
128
129
130
131
# File '../../src/modules/Nfs.rb', line 125

def GetOptionsAndEntriesMap(settings, global_options, entries)
  settings = deep_copy(settings)
  global_options.value = Builtins.remove(settings, "nfs_entries")
  entries.value = Ops.get_list(settings, "nfs_entries", [])

  nil
end

- (Object) GetOptionsAndEntriesSLE11(settings, global_options, entries)



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File '../../src/modules/Nfs.rb', line 107

def GetOptionsAndEntriesSLE11(settings, global_options, entries)
  settings = deep_copy(settings)
  if Builtins.haskey(Ops.get(settings, 0, {}), "enable_nfs4") ||
      Builtins.haskey(Ops.get(settings, 0, {}), "idmapd_domain")
    global_options.value = Ops.get(settings, 0, {})
    settings = Builtins.remove(settings, 0)
  end

  entries.value = Convert.convert(
    settings,
    :from => "list <map>",
    :to   => "list <map <string, any>>"
  )

  nil
end

- (Object) gsub(regex, replacement, s)

(like awk gsub, but return the result, not number of replacements) replaces from back!

Parameters:

  • regex (String)

    regular expression to replace

  • replacement (String)

    the replacement string

  • s (String)

    where to replace

Returns:

  • the changed string



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File '../../src/modules/Nfs.rb', line 290

def gsub(regex, replacement, s)
  temp = nil
  while true
    # argh, regexpsub logs an error if it cannot sub
    break if !Builtins.regexpmatch(s, Ops.add(Ops.add(".*", regex), ".*"))
    temp = Builtins.regexpsub(
      s,
      Ops.add(Ops.add("(.*)", regex), "(.*)"),
      Ops.add(Ops.add("\\1", replacement), "\\2")
    )
    break if temp == nil
    s = temp
  end
  s
end

- (Object) Import(settings)

Get all NFS configuration from a map. When called by nfs_auto (preparing autoinstallation data) the map may be empty.

Parameters:

  • settings (Hash{String => Object})

    a map($) of nfs_entries

Returns:

  • success



231
232
233
234
# File '../../src/modules/Nfs.rb', line 231

def Import(settings)
  settings = deep_copy(settings)
  ImportAny(settings)
end

- (Object) ImportAny(settings)



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
213
214
215
216
217
218
219
220
221
222
223
224
# File '../../src/modules/Nfs.rb', line 181

def ImportAny(settings)
  settings = deep_copy(settings)
  # ($) since oS-1x.x, settings was changed to be a map,
  # which is incompatible with the sle profiles;
  # it owuld be nice to make it compatible again
  # whjich this code is readyu to, but the Autoyast engine isn't.
  global_options = {}
  entries = []
  global_options_ref = arg_ref(global_options)
  entries_ref = arg_ref(entries)
  GetOptionsAndEntries(settings, global_options_ref, entries_ref)
  global_options = global_options_ref.value
  entries = entries_ref.value

  return false if Builtins.find(entries) { |e| !ValidateAyNfsEntry(e) } != nil

  entries = FillEntriesDefaults(entries)

  @nfs4_enabled = Ops.get_boolean(global_options, "enable_nfs4") do
    ReadNfs4()
  end
  @nfs_gss_enabled = Ops.get_boolean(global_options, "enable_nfs_gss") do
    ReadNfsGss()
  end
  @idmapd_domain = Ops.get_string(global_options, "idmapd_domain") do
    ReadIdmapd()
  end

  # vfstype can override a missing enable_nfs4
  @nfs4_enabled = true if Builtins.find(entries) do |entry|
    Ops.get_string(entry, "vfstype", "") == "nfs4"
  end != nil

  @nfs_entries = Builtins.maplist(entries) do |entry|
    {
      "spec"    => Ops.get_string(entry, "server_path", ""),
      "file"    => Ops.get_string(entry, "mount_point", ""),
      "vfstype" => Ops.get_string(entry, "vfstype", ""),
      "mntops"  => Ops.get_string(entry, "nfs_options", "")
    }
  end

  true
end

- (Object) main



22
23
24
25
26
27
28
29
30
31
32
33
34
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
# File '../../src/modules/Nfs.rb', line 22

def main

  textdomain "nfs"

  Yast.import "FileUtils"
  Yast.import "Mode"
  Yast.import "NfsOptions"
  Yast.import "Report"
  Yast.import "Service"
  Yast.import "Summary"
  Yast.import "SuSEFirewall"
  Yast.import "Progress"
  Yast.import "PackageSystem"
  Yast.import "PackagesProposal"
  Yast.import "Wizard"

  Yast.include self, "nfs/routines.rb"


  # default value of settings modified
  @modified = false

  # Should fstab reading be skipped ? (yes if we're
  # embedded in partitioner)
  @skip_fstab = false

  # Required packages
  @required_packages = ["nfs-client"]

  # eg.: [ $["spec": "moon:/cheese", file: "/mooncheese", "mntops": "defaults"], ...]
  @nfs_entries = []

  # Read only, intended for checking mount-point uniqueness.
  @non_nfs_entries = []

  @nfs4_enabled = nil

  @nfs_gss_enabled = nil

  @idmapd_domain = ""

  @portmapper = ""

  # list of created directories
  @created_dirs = []
end

- (String) Mount(server, share, mpoint, options, type)

Mount NFS directory

Parameters:

  • server (String)

    remote server name

  • share (String)

    name of the exported directory

  • mpoint (String)

    mount point (can be empty or nil, in this case it will be mounted in temporary directory)

  • options (String)

    mount options - e.g. “ro,hard,intr”, see man nfs

  • type (String)

    nfs type (nfs vs. nfsv4) - if empty, 'nfs' is used

Returns:

  • (String)

    directory where volume was mounted or nil if mount failed



575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
# File '../../src/modules/Nfs.rb', line 575

def Mount(server, share, mpoint, options, type)
  return nil if Builtins.size(server) == 0 || Builtins.size(share) == 0

  # check if options are valid
  if Ops.greater_than(Builtins.size(options), 0)
    if NfsOptions.validate(options) != ""
      Builtins.y2warning("invalid mount options: %1", options)
      return nil
    end
  end

  # mount to temporary directory if mpoint is nil
  if mpoint == nil
    tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir")))

    if tmpdir == nil || tmpdir == ""
      Builtins.y2security("Warning: using /tmp directory!")
      tmpdir = "/tmp"
    end

    mpoint = Ops.add(
      Ops.add(tmpdir, "/nfs"),
      Builtins.sformat("%1", Builtins.size(@created_dirs))
    ) # use num to allow parallel mounts
  end

  # check mount point
  if CheckPath(mpoint) == false
    # mount point is not valid
    Builtins.y2warning("invalid mount point: %1", mpoint)
    return nil
  end

  portmapper = FindPortmapper()
  # check whether portmapper is installed
  if IsPortmapperInstalled(portmapper) == false
    Builtins.y2warning("Neither rpcbind nor portmap is installed")
    return nil
  end


  # start portmapper if it isn't running
  if Service.Status(portmapper) != 0
    if Service.Start(portmapper) == false
      Builtins.y2warning("%1 cannot be started", portmapper)
      return nil
    end
  end

  # create mount point if it doesn't exist
  if SCR.Read(path(".target.dir"), mpoint) == nil
    if !Convert.to_boolean(SCR.Execute(path(".target.mkdir"), mpoint))
      Builtins.y2warning("cannot create mount point %1", mpoint)
      return nil
    end

    # remember name of created directory
    @created_dirs = Builtins.add(@created_dirs, mpoint)
  end

  # build mount command
  command = Builtins.sformat(
    "/bin/mount %1 %2 %3:%4 %5",
    Ops.greater_than(Builtins.size(options), 0) ?
      Ops.add("-o ", options) :
      "",
    Ops.add("-t ", Ops.greater_than(Builtins.size(type), 0) ? type : "nfs"),
    server,
    share,
    mpoint
  )

  # execute mount command
  SCR.Execute(path(".target.bash"), command) == 0 ? mpoint : nil
end

- (Object) ProbeExports(server, v4)

Probe a server for its exports.

Parameters:

  • server (String)

    IP or hostname

  • v4 (Boolean)

    Use NFSv4?

Returns:

  • a list of exported paths



732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
# File '../../src/modules/Nfs.rb', line 732

def ProbeExports(server, v4)
  dirs = []

  # showmounts does not work for nfsv4 (#466454)
  if v4
    tmpdir = Mount(server, "/", nil, "ro", "nfs4")

    # This is completely stupid way how to explore what can be mounted
    # and I even don't know if it is correct. Maybe 'find tmpdir -xdev -type d'
    # should be used instead. No clue :(
    dirs = Builtins.maplist(
      Convert.convert(
        SCR.Read(path(".target.dir"), tmpdir),
        :from => "any",
        :to   => "list <string>"
      )
    ) { |dirent| Ops.add("/", dirent) }
    dirs = Builtins.prepend(dirs, "/")
    Unmount(tmpdir)
  else
    dirs = Convert.convert(
      SCR.Read(path(".net.showexports"), server),
      :from => "any",
      :to   => "list <string>"
    )
  end

  dirs = ["internal error"] if dirs == nil
  deep_copy(dirs)
end

- (Object) ProbeServers

Probe the LAN for NFS servers. Uses RPC broadcast to mountd.

Returns:

  • a list of hostnames



704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
# File '../../src/modules/Nfs.rb', line 704

def ProbeServers
  #newer, shinier, better rpcinfo from rpcbind (#450056)
  prog_name = "/sbin/rpcinfo"
  delim = ""

  #fallback from glibc (uses different field separators, grr :( )
  if !FileUtils.Exists(prog_name)
    prog_name = "/usr/sbin/rpcinfo"
    delim = "-d ' ' "
  end

  # #71064
  # this works also if ICMP broadcasts are ignored
  cmd = Ops.add(
    Ops.add(Ops.add(prog_name, " -b mountd 1 | cut "), delim),
    "-f 2 | sort -u"
  )
  out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))
  hosts = Builtins.filter(
    Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")
  ) { |s| s != "" }
  deep_copy(hosts)
end

- (Object) Read

Reads NFS settings from the SCR (.etc.fstab)

Returns:

  • true on success



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File '../../src/modules/Nfs.rb', line 340

def Read
  #Read /etc/fstab if we're running standalone (otherwise, libstorage does the job)
  if !@skip_fstab
    fstab = Convert.convert(
      SCR.Read(path(".etc.fstab")),
      :from => "any",
      :to   => "list <map <string, any>>"
    )
    fstab = UnescapeSpaces(fstab)
    Builtins.y2milestone("fstab: %1", fstab)

    # For simplicity, this leaves also the unused fileds in the maps.
    @nfs_entries = Builtins.filter(fstab) do |entry|
      Ops.get_string(entry, "vfstype", "") == "nfs" ||
        Ops.get_string(entry, "vfstype", "") == "nfs4"
    end
    @non_nfs_entries = Builtins.filter(fstab) do |entry|
      Ops.get_string(entry, "vfstype", "") != "nfs" &&
        Ops.get_string(entry, "vfstype", "") != "nfs4"
    end
  end

  @nfs4_enabled = ReadNfs4()
  @nfs_gss_enabled = ReadNfsGss()
  @idmapd_domain = ReadIdmapd()

  progress_orig = Progress.set(false)
  SuSEFirewall.Read
  Progress.set(progress_orig)

  @portmapper = FindPortmapper()
  #There is neither rpcbind  nor portmap
  if @portmapper == ""
    #so let's install rpcbind (default since #423026)
    @required_packages = Builtins.add(@required_packages, "rpcbind")
    @portmapper = "rpcbind"
  end
  if @nfs4_enabled
    @required_packages = Builtins.add(@required_packages, "nfsidmap")
  end

  if Mode.installation
    Builtins.foreach(@required_packages) do |p|
      PackagesProposal.AddResolvables("yast2-nfs-client", :package, [p])
    end
  else
    if !PackageSystem.CheckAndInstallPackagesInteractive(@required_packages)
      return false
    end
  end

  true
end

- (Object) ReadIdmapd



91
92
93
# File '../../src/modules/Nfs.rb', line 91

def ReadIdmapd
  Convert.to_string(SCR.Read(path(".etc.idmapd_conf.value.General.Domain")))
end

- (Object) ReadNfs4



83
84
85
# File '../../src/modules/Nfs.rb', line 83

def ReadNfs4
  SCR.Read(path(".sysconfig.nfs.NFS4_SUPPORT")) == "yes"
end

- (Object) ReadNfsGss



87
88
89
# File '../../src/modules/Nfs.rb', line 87

def ReadNfsGss
  SCR.Read(path(".sysconfig.nfs.NFS_SECURITY_GSS")) == "yes"
end

- (Object) SetModified

Function sets internal variable, which indicates, that any settings were modified, to "true"



71
72
73
74
75
# File '../../src/modules/Nfs.rb', line 71

def SetModified
  @modified = true

  nil
end

- (Object) Summary

Summary()

Returns:

  • Html formatted configuration summary



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# File '../../src/modules/Nfs.rb', line 550

def Summary
  summary = ""
  nc = Summary.NotConfigured
  # summary header
  summary = Summary.AddHeader(summary, _("NFS Entries"))
  entries = Builtins.size(@nfs_entries)
  Builtins.y2milestone("Entries: %1", @nfs_entries)
  # summary item, %1 is a number
  configured = Builtins.sformat(_("%1 entries configured"), entries)
  summary = Summary.AddLine(
    summary,
    Ops.greater_than(entries, 0) ? configured : nc
  )
  summary
end

- (Object) UnescapeSpaces(entries)

Un-escape spaces “040” -> “ ” in all values of all entries

Parameters:

  • entries (Array<Hash{String => Object>})

    a list of maps, such as nfs_entries

Returns:

  • escaped entries



318
319
320
321
322
323
324
325
326
327
# File '../../src/modules/Nfs.rb', line 318

def UnescapeSpaces(entries)
  entries = deep_copy(entries)
  Builtins.maplist(entries) { |entry| Builtins.mapmap(entry) do |key, value|
    {
      key => Ops.is_string?(value) ?
        UnescapeSpaces1(Convert.to_string(value)) :
        value
    }
  end }
end

- (Object) UnescapeSpaces1(s)

Un-escape spaces “040” -> “ ”

Parameters:

  • s (String)

    string or nil

Returns:

  • escaped string or nil



309
310
311
312
313
# File '../../src/modules/Nfs.rb', line 309

def UnescapeSpaces1(s)
  # escaped space, \040, is /\\040/
  # which is "\\\\040"
  s == nil ? nil : gsub("\\\\040", " ", s)
end

- (Boolean) Unmount(mpoint)

Unmount NFS directory from the system

Parameters:

  • mpoint (String)

    NFS mount point to unmount

Returns:

  • (Boolean)

    true on success



654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File '../../src/modules/Nfs.rb', line 654

def Unmount(mpoint)
  return false if Builtins.size(mpoint) == 0

  # unmount directory if it's NFS mountpoint
  mounts = Convert.convert(
    SCR.Read(path(".proc.mounts")),
    :from => "any",
    :to   => "list <map <string, any>>"
  )
  found = false

  Builtins.foreach(mounts) do |m|
    type = Ops.get_string(m, "vfstype")
    file = Ops.get_string(m, "file")
    found = true if (type == "nfs" || type == "nfs4") && file == mpoint
  end 


  if found
    command = Builtins.sformat("/bin/umount %1", mpoint)

    return false if SCR.Execute(path(".target.bash"), command) != 0
  else
    Builtins.y2warning("%1 is not NFS mount point", mpoint)
    return false
  end

  # if the directory was created by Mount call and it is empty then remove it
  if Builtins.contains(@created_dirs, mpoint) &&
      SCR.Read(path(".target.dir"), mpoint) == []
    command = Builtins.sformat("/bin/rmdir %1", mpoint)

    return false if SCR.Execute(path(".target.bash"), command) != 0

    # remove directory from list
    @created_dirs = Builtins.filter(@created_dirs) { |d| d != mpoint }
  end

  true
end

- (Object) ValidateAyNfsEntry(entry)



95
96
97
98
99
100
101
102
103
104
105
# File '../../src/modules/Nfs.rb', line 95

def ValidateAyNfsEntry(entry)
  entry = deep_copy(entry)
  valid = true
  Builtins.foreach(["server_path", "mount_point", "nfs_options"]) do |k|
    if !Builtins.haskey(entry, k)
      Builtins.y2error("Missing at Import: '%1'.", k)
      valid = false
    end
  end
  valid
end

- (Object) Write

Writes the NFS client configuration and starts/stops the service. (No parameters because it is too short to abort)

Returns:

  • true on success



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File '../../src/modules/Nfs.rb', line 489

def Write
  if WriteOnly()
    # dialog label
    Progress.New(
      _("Writing NFS Configuration"),
      " ",
      2,
      [
        # progress stage label
        _("Stop services"),
        # progress stage label
        _("Start services")
      ],
      [
        # progress step label
        _("Stopping services..."),
        # progress step label
        _("Starting services..."),
        # final progress step label
        _("Finished")
      ],
      ""
    )

    # help text
    Wizard.RestoreHelp(_("Writing NFS client settings. Please wait..."))

    Progress.NextStage

    Service.Stop("nfs")

    Progress.NextStage
    if Ops.greater_than(Builtins.size(@nfs_entries), 0)
      if Service.Status(@portmapper) != 0
        # portmap must not be started if it is running already (see bug # 9999)
        Service.Start(@portmapper)
      end

      Service.Start("nfs")
      # #74597: if all mounts are noauto, $? is 6 (unconfigured)
      status = Service.Status("nfs")
      if status != 0 && status != 6
        # error popup message
        Report.Error(_("Unable to mount the NFS entries from /etc/fstab."))
        return false
      end
    end

    progress_orig = Progress.set(false)
    SuSEFirewall.ActivateConfiguration
    Progress.set(progress_orig)

    Progress.NextStage
    return true
  else
    return false
  end
end

- (Object) WriteOnly

Writes the NFS client configuration without starting/stopping the service. Autoinstallation uses this and then calls SuSEconfig only once and starts the services together. (No parameters because it is too short to abort)

Returns:

  • true on success



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File '../../src/modules/Nfs.rb', line 400

def WriteOnly
  # Merge with non-nfs entries from fstab:
  fstab = Convert.convert(
    SCR.Read(path(".etc.fstab")),
    :from => "any",
    :to   => "list <map <string, any>>"
  )
  # unescape deferred for optimization
  fstab = Builtins.filter(fstab) do |entry|
    Ops.get_string(entry, "vfstype", "") != "nfs" &&
      Ops.get_string(entry, "vfstype", "") != "nfs4"
  end
  fstab = UnescapeSpaces(fstab)

  Builtins.foreach(@nfs_entries) do |entry|
    fstab = Builtins.add(
      fstab,
      Convert.convert(
        Builtins.union(
          entry,
          { "freq" => 0, "passno" => 0 } #"vfstype": "nfs",
        ),
        :from => "map",
        :to   => "map <string, any>"
      )
    )
    # create mount points
    file = Ops.get_string(entry, "file", "")
    if !Convert.to_boolean(SCR.Execute(path(".target.mkdir"), file))
      # error popup message
      Report.Warning(
        Builtins.sformat(_("Unable to create directory '%1'."), file)
      )
    end
  end

  Builtins.y2milestone("fstab: %1", fstab)

  SCR.Execute(
    path(".target.bash"),
    "/bin/cp $ORIG $BACKUP",
    { "ORIG" => "/etc/fstab", "BACKUP" => "/etc/fstab.YaST2.save" }
  )

  fstab = EscapeSpaces(fstab)
  if !SCR.Write(path(".etc.fstab"), fstab)
    # error popup message
    Report.Error(
      _(
        "Unable to write to /etc/fstab.\n" +
          "No changes will be made to the\n" +
          "the NFS client configuration.\n"
      )
    )
    return false
  end

  @portmapper = FindPortmapper()
  if Builtins.size(@nfs_entries) != 0
    Service.Enable(@portmapper)
    Service.Enable("nfs")
    # #36737: it just runs sm_notify at boot time
    # replaces rpc.statd
    Service.Enable("nfsboot")
  end

  if @nfs4_enabled == true
    SCR.Write(path(".sysconfig.nfs.NFS4_SUPPORT"), "yes")
    SCR.Write(path(".etc.idmapd_conf.value.General.Domain"), @idmapd_domain)
    # flush the changes
    SCR.Write(path(".etc.idmapd_conf"), nil)
  elsif @nfs4_enabled == false
    SCR.Write(path(".sysconfig.nfs.NFS4_SUPPORT"), "no")
  end
  SCR.Write(
    path(".sysconfig.nfs.NFS_SECURITY_GSS"),
    @nfs_gss_enabled ? "yes" : "no"
  )

  progress_orig = Progress.set(false)
  SuSEFirewall.WriteOnly
  Progress.set(progress_orig)

  true
end