Module: Yast::HttpServerWizardDialogInclude

Defined in:
../../src/include/http-server/wizard-dialog.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) initialize_http_server_wizard_dialog(include_target)



11
12
13
14
15
16
17
18
# File '../../src/include/http-server/wizard-dialog.rb', line 11

def initialize_http_server_wizard_dialog(include_target)
  textdomain "http-server"
  Yast.import "HttpServerWidgets"
  Yast.import "Wizard"
  Yast.import "CWM"
  Yast.import "Label"
  Yast.import "HttpServer"
end

- (Symbol) WizardSequence1

Sequention used for determining on which ip adresses and port apache2 will listen and if firewall is enebled whether to open firewall on this port.

Returns:

  • (Symbol)

    (back,abort, `next)



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
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
# File '../../src/include/http-server/wizard-dialog.rb', line 23

def WizardSequence1
  caption = _("HTTP Server Wizard (1/5)--Network Device Selection")
  contents = HBox(
    HStretch(),
    VBox(
      VSpacing(0.5),
      "open_port",
      VSpacing(0.5),
      "listen_interfaces",
      VSpacing(0.5),
      "firewall_adapt",
      VSpacing(8)
    ),
    HStretch()
  )
  widget_names = ["open_port", "listen_interfaces", "firewall_adapt"]
  w = CWM.CreateWidgets(widget_names, HttpServerWidgets.widgets)
  help = Ops.add(
    "<h3>" + _("Network Device Selection") + "</h3>",
    CWM.MergeHelps(w)
  )
  contents = CWM.PrepareDialog(contents, w)

  Wizard.SetContentsButtons(
    caption,
    contents,
    help,
    Label.BackButton,
    Label.NextButton
  )
  Wizard.DisableBackButton
  Wizard.SetAbortButton(:abort, Label.CancelButton)

  event = {}
  ret = CWM.Run(
    w,
    { :abort => fun_ref(method(:ReallyAbort), "boolean ()") }
  )

  if ret == :next
    #*	Save entred parameters to map
    if_all = Builtins.maplist(HttpServer.ip2device) { |ip, dev| ip }
    if_sel = Convert.convert(
      UI.QueryWidget(Id("multi_sel_box"), :SelectedItems),
      :from => "any",
      :to   => "list <string>"
    )
    Builtins.y2milestone("All interfaces : %1", if_all)
    Builtins.y2milestone(
      "going next %1",
      UI.QueryWidget(Id("open_port"), :Value)
    )
    Builtins.y2milestone("network interfaces : %1", if_sel)
    all = true
    finded = false
    Builtins.foreach(if_all) do |interface|
      finded = false
      Builtins.foreach(if_sel) do |selected|
        finded = true if selected == interface
      end
      all = false if !finded
    end
    Builtins.y2milestone("All: %1", all)
    # save port information
    Builtins.foreach(YaST::HTTPDData.GetCurrentListen) do |listens|
      YaST::HTTPDData.DeleteListen(
        Builtins.tointeger(Ops.get_string(listens, "PORT", "80")),
        Builtins.tointeger(Ops.get_string(listens, "PORT", "80")),
        Ops.get_string(listens, "ADDRESS", "")
      )
    end
    # save interface information
    if all == true
      YaST::HTTPDData.CreateListen(
        Builtins.tointeger(UI.QueryWidget(Id("open_port"), :Value)),
        Builtins.tointeger(UI.QueryWidget(Id("open_port"), :Value)),
        ""
      )
    else
      # save firewall open port information
      Builtins.foreach(if_sel) do |ip|
        YaST::HTTPDData.CreateListen(
          Builtins.tointeger(UI.QueryWidget(Id("open_port"), :Value)),
          Builtins.tointeger(UI.QueryWidget(Id("open_port"), :Value)),
          ip
        )
        Builtins.y2milestone("Listen on : %1", ip)
      end
      HttpServer.modified = true
    end
  end
  Builtins.y2milestone(
    "Listen string : %1",
    YaST::HTTPDData.GetCurrentListen
  )
  Convert.to_symbol(ret)
end

- (Symbol) WizardSequence2

Sequence to choose some script language modules

Returns:

  • (Symbol)

    (back,abort, `next)



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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File '../../src/include/http-server/wizard-dialog.rb', line 124

def WizardSequence2
  caption = _("HTTP Server Wizard (2/5)--Modules")
  contents = Top("script_modules")

  widget_names = ["script_modules"]
  w = CWM.CreateWidgets(widget_names, HttpServerWidgets.widgets)
  help = Ops.add("<h3>" + _("Modules") + "</h3>", CWM.MergeHelps(w))
  contents = CWM.PrepareDialog(contents, w)

  Wizard.SetContentsButtons(
    caption,
    contents,
    help,
    Label.BackButton,
    Label.NextButton
  )
  Wizard.SetAbortButton(:abort, Label.CancelButton)

  event = {}
  ret = CWM.Run(
    w,
    { :abort => fun_ref(method(:ReallyAbort), "boolean ()") }
  )
  if ret == :next
    enable_php5 = Convert.to_boolean(
      UI.QueryWidget(Id(:scr_mod_php5), :Value)
    )
    enable_perl = Convert.to_boolean(
      UI.QueryWidget(Id(:scr_mod_perl), :Value)
    )
    enable_python = Convert.to_boolean(
      UI.QueryWidget(Id(:scr_mod_python), :Value)
    )
    #        boolean enable_ruby=(boolean) UI::QueryWidget( `id(`scr_mod_ruby), `Value );

    Builtins.y2milestone("Saving script modules")
    Builtins.y2milestone("PHP5 support %1", enable_php5)
    Builtins.y2milestone("Perl support %1", enable_perl)
    Builtins.y2milestone("Python support %1", enable_python)
    #	y2milestone("Ruby support %1", enable_ruby);
    # create list of all standard modules
    existing = Builtins.maplist(YaST::HTTPDData.GetKnownModules) do |mod|
      YaST::HTTPDData.ModifyModuleList(
        [Ops.get_locale(mod, "name", _("unknown"))],
        Ops.get_locale(mod, "default", _("0")) == "1"
      )
    end
    # add selected modules to that list
    YaST::HTTPDData.ModifyModuleList(["php5"], enable_php5)
    YaST::HTTPDData.ModifyModuleList(["perl"], enable_perl)
    YaST::HTTPDData.ModifyModuleList(["python"], enable_python)
    #        YaST::HTTPDData::ModifyModuleList ([ "ruby" ], enable_ruby);

    HttpServer.modified = true
  end
  Convert.to_symbol(ret)
end

- (Symbol) WizardSequence3

Sequence to configure default host parameters

Returns:

  • (Symbol)

    (back,abort, `next)



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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File '../../src/include/http-server/wizard-dialog.rb', line 185

def WizardSequence3
  caption = _("HTTP Server Wizard (3/5)--Default Host")
  w = CWM.CreateWidgets(["MAIN_HOST"], HttpServerWidgets.widgets)
  contents = HBox(
    HSpacing(1),
    VBox(VSpacing(1), Ops.get_term(w, [0, "widget"]) { VSpacing(0) }, VSpacing(
      1
    )),
    HSpacing(1)
  )

  # dialog caption
  help = CWM.MergeHelps(w)

  Wizard.SetContentsButtons(
    caption,
    contents,
    help,
    Label.BackButton,
    Label.NextButton
  )
  Wizard.SetAbortButton(:abort, Label.CancelButton)

  servername = Convert.to_string(
    HttpServerWidgets.get_host_value(
      "ServerName",
      YaST::HTTPDData.GetHost("main"),
      ""
    )
  )

  serveradmin = Convert.to_string(
    HttpServerWidgets.get_host_value(
      "ServerAdmin",
      YaST::HTTPDData.GetHost("main"),
      ""
    )
  )

  hostname = Convert.to_map(
    SCR.Execute(path(".target.bash_output"), "/bin/hostname")
  )
  Builtins.y2milestone(
    "Hostname : %1",
    Ops.get_string(hostname, "stdout", "")
  )
  # if no ServerName or ServerAdmin readed from configuration file, the values based on machine hostname are used
  if Builtins.size(servername) == 0
    YaST::HTTPDData.ModifyHost(
      "main",
      HttpServerWidgets.set_host_value(
        "ServerName",
        YaST::HTTPDData.GetHost("main"),
        Ops.get_string(hostname, "stdout", "")
      )
    )
  end
  if Builtins.size(serveradmin) == 0
    YaST::HTTPDData.ModifyHost(
      "main",
      HttpServerWidgets.set_host_value(
        "ServerAdmin",
        YaST::HTTPDData.GetHost("main"),
        Ops.add("root@", Ops.get_string(hostname, "stdout", ""))
      )
    )
  end

  CWM.Run(w, { :abort => fun_ref(method(:Abort), "boolean ()") })
end

- (Symbol) WizardSequence4

Sequence to cunfigure virtual hosts (add, remove, edit) and to change default host status

Returns:

  • (Symbol)

    (back,abort, `next)



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File '../../src/include/http-server/wizard-dialog.rb', line 259

def WizardSequence4
  caption = _("HTTP Server Wizard (4/5)--Virtual Hosts")

  w = CWM.CreateWidgets(["hosts"], HttpServerWidgets.widgets)
  contents = HBox(
    HSpacing(1),
    VBox(VSpacing(1), Ops.get_term(w, [0, "widget"]) { VSpacing(0) }, VSpacing(
      1
    )),
    HSpacing(1)
  )

  # dialog caption
  help = CWM.MergeHelps(w)

  Wizard.SetContentsButtons(
    caption,
    contents,
    help,
    Label.BackButton,
    Label.NextButton
  )
  Wizard.SetAbortButton(:abort, Label.CancelButton)

  CWM.Run(w, { :abort => fun_ref(method(:Abort), "boolean ()") })
end

- (Symbol) WizardSequence5

Sequence to configure whether apache2 starts on boot or not (manually). Here is possible save all settings and exit or start expert configuration.

Returns:

  • (Symbol)

    (back,abort, `next)



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File '../../src/include/http-server/wizard-dialog.rb', line 290

def WizardSequence5
  caption = _("HTTP Server Wizard (5/5)--Summary")

  contents = VBox("booting", "summary_text", "expert_conf")
  widget_names = ["booting", "summary_text", "expert_conf"]
  w = CWM.CreateWidgets(widget_names, HttpServerWidgets.widgets)
  help = CWM.MergeHelps(w)
  contents = CWM.PrepareDialog(contents, w)

  Wizard.SetContentsButtons(
    caption,
    contents,
    help,
    Label.BackButton,
    Label.FinishButton
  )
  Wizard.SetAbortButton(:abort, Label.CancelButton)

  event = {}
  ret = CWM.Run(w, { :abort => fun_ref(method(:Abort), "boolean ()") })
  Builtins.y2milestone("Return value from 5.th dialog : %1", ret)
  Convert.to_symbol(ret)
end