Module: Yast::NisServerSlaveInclude

Defined in:
../../src/include/nis_server/slave.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) initialize_nis_server_slave(include_target)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File '../../src/include/nis_server/slave.rb', line 42

def initialize_nis_server_slave(include_target)
  Yast.import "UI"

  textdomain "nis_server"

  Yast.import "Wizard"
  Yast.import "Popup"

  Yast.import "CWMFirewallInterfaces"
  Yast.import "NisServer"
  Yast.import "Nis"
  Yast.import "Address"
  Yast.include include_target, "nis_server/routines.rb"
end

- (Object) SlaveDialog

Slave dialog

Returns:

  • back,abort or `next



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
113
114
115
116
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File '../../src/include/nis_server/slave.rb', line 59

def SlaveDialog
  firewall_widget = GetFirewallWidget()
  firewall_layout = Ops.get_term(firewall_widget, "custom_widget", VBox())

  # help text 1/2
  helptext = _(
    "<p>Enter the NIS <b>domain</b> and the IP <b>address</b> or host name of the master NIS server.</p>"
  )
  # help text 2/2
  helptext = Ops.add(
    Ops.add(
      helptext,
      _(
        "<p>If this host is also a NIS client using this machine as a server, check the corresponding option.</p>"
      )
    ),
    Ops.get_string(firewall_widget, "help", "")
  )

  contents = HVSquash(
    VBox(
      # textentry label
      InputField(
        Id(:domain),
        Opt(:hstretch),
        _("N&IS domain name:"),
        NisServer.domain
      ),
      VSpacing(0.5),
      InputField(
        Id(:master_ip),
        Opt(:hstretch),
        # text entry label
        "NIS &master server:",
        NisServer.ui_master_ip
      ),
      VSpacing(),
      Left(
        CheckBox(
          Id(:also_client),
          # checkbox label
          _("This host is also a NIS &client"),
          NisServer.start_ypbind
        )
      ),
      VSpacing(2),
      firewall_layout
    )
  )

  # To translators: dialog label
  Wizard.SetContents(
    _("Slave Server Setup"),
    contents,
    helptext,
    true,
    true
  )

  CWMFirewallInterfaces.OpenFirewallInit(firewall_widget, "")

  event = {}
  ui = nil
  begin
    event = UI.WaitForEvent
    ui = Ops.get(event, "ID")
    CWMFirewallInterfaces.OpenFirewallHandle(firewall_widget, "", event)
    ui = :abort if ui == :cancel

    if ui == :next
      master_ip = Convert.to_string(UI.QueryWidget(Id(:master_ip), :Value))
      domainname = Convert.to_string(UI.QueryWidget(Id(:domain), :Value))
      start_ypbind = Convert.to_boolean(
        UI.QueryWidget(Id(:also_client), :Value)
      )
      if !Address.Check4(master_ip)
        # To translators: error message
        UI.SetFocus(Id(:master_ip))
        Popup.Error(Address.Valid4)
        ui = :again
        next
      elsif !Nis.check_nisdomainname(domainname)
        UI.SetFocus(Id(:domain))
        Popup.Error(Nis.valid_nisdomainname)
        ui = :again
        next
      end
      if master_ip != NisServer.ui_master_ip ||
          domainname != NisServer.domain ||
          start_ypbind != NisServer.start_ypbind
        NisServer.modified = true
      end

      CheckForDHCPClient(domainname)
      CWMFirewallInterfaces.OpenFirewallStore(firewall_widget, "", event)
      NisServer.start_ypbind = start_ypbind
      NisServer.ui_master_ip = master_ip
      NisServer.domain = domainname
    end

    ui = :again if ui == :abort && !Popup.ReallyAbort(NisServer.modified)
  end until ui == :next || ui == :back || ui == :abort

  Convert.to_symbol(ui)
end