2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
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
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
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
255
256
257
258
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
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
|
# File 'lib/six-updater-web/app/controllers/main_controller.rb', line 2
def index
@msg, @error, @status = [], [], []
@pm = false
@skip, @install, @check, @disabled, @special = [], [], [], [], []
preset, queryserver, server, action, setting, reset, ok = nil, nil, nil, nil, nil, false, true
grab = false
@force = false
unless params["system"].nil? || params["system"]["force"].nil?
@force = params["system"]["force"] == "1"
end
save_fav = true
@system_setting = SystemSetting.singleton
@autoskip = @system_setting.autoskip
@autoskip = true if @autoskip.nil?
@beta = @system_setting.beta
@server_bool = @system_setting.server_bool
@server_check = false
@inweb = @system_setting.inweb
@queryserver = Queryserver.new
if params[:kill]
procs = params[:kill].split(",")
procs.each { |entry| Six::Appmanager.kill(entry.to_i); @msg << "Process killed: #{entry}" } sleep 1
end
if @system_setting.synchronized_at
ok = false if @system_setting.synchronized_at > 30.minutes.ago
end
if ok
@msg << "Auto Synchronize: " + begin
@system_setting.sync
rescue => e
logger.debug "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
"FAILURE: #{$!}"
end
end
gs_ok, gs_geo = true, true
if @system_setting.gamespied_at
gs_ok = false if @system_setting.gamespied_at > 30.minutes.ago
end
params["commit"] = "synchronize" if params["portalsync"]
params["commit"] = "update_gamespy" if params["serversync"]
unless params["commit"]
params["commit"] = if gs_ok
gs_geo = false
"update_gamespy"
else
"none"
end
end
case params["commit"].downcase
when "none"
grab = true
save_fav = false
when "exec"
save_fav = false
params["commit"] = "execute"
when "synchronize"
if !ok
@msg << @system_setting.sync
end
grab = true
when "show status"
grab = true
params["all"] = ""
when "reset skip status"
reset = true
when "reset all mods skip status"
reset = true
grab = true
params["all"] = ""
when "prune_gamespy"
@msg << "Pruning Gamespy"
Queryserver.prune
when "clean_gamespy"
@msg << "Cleaning Gamespy"
Queryserver.clean
when "purge_gamespy"
d = false
if params["really"] && params["really"]["sure"] == "1"
Queryserver.purge
@msg << "Purged Gamespy..."
d = true
end
@error << "<b>ERROR: Please confirm by checking the checkbox</b>" if !d
end
begin
preset = Sixconfig.find(@system_setting.favorite_preset)
rescue
begin
preset = Sixconfig.find(:first) rescue
end
end
begin
setting = Appsetting.find(@system_setting.favorite_settings_profile)
rescue
end
begin
action = Action.find(@system_setting.favorite_action)
rescue
end
preset = fetch_param([:config], Sixconfig, preset)
action = fetch_param([:act], Action, action)
setting = fetch_param([:setting], Appsetting, setting)
begin
queryserver = Queryserver.find(@system_setting.favorite_server)
rescue
end
queryserver = fetch_param([:gamespy], Queryserver, queryserver)
if queryserver
@queryserver = queryserver
server = queryserver.dynamic_server
end
if params[:system]
@beta = case params[:system][:beta]
when "default"
nil
when "true"
true
else
false
end
@server_bool = case params[:system][:server_bool]
when "default"
nil
when "true"
true
else
false
end
@autoskip = (params[:system][:autoskip] == "1")
@inweb = (params[:system][:inweb] == "1")
end
if save_fav
@system_setting.favorite_server = if queryserver queryserver.id unless queryserver.new_record?
else
nil
end
@system_setting.favorite_preset = if preset
preset.id unless preset.new_record?
else
nil
end
@system_setting.favorite_action = if action
action.id unless action.new_record?
else
nil
end
@system_setting.favorite_settings_profile = if setting
setting.id unless setting.new_record?
else
nil
end
@system_setting.beta = @beta
@system_setting.server_bool = @server_bool
@system_setting.autoskip = @autoskip
@system_setting.inweb = @inweb
@system_setting.save
end
if preset
@status << "Preset: <a href='/sixconfigs/edit/#{preset.id}' title='#{preset.mods.map{|e| e.name}.join(", ")}'>#{preset.name}</a>"
else
@status << "No preset selected!"
preset = Sixconfig.new(:name => "Dynamic")
end
if grab && params["all"]
preset.mods += Mod.find(:all)
end
unless params["all"]
if server
@status << "Override server: <a href='/queryservers/edit/#{queryserver.id}' title='#{queryserver.country}, #{queryserver.ping}ms .Mods: #{queryserver.mods.map{|e| e.name}.join(", ")}'>#{queryserver.to_label}</a>"
else
if preset.get_server
server = preset.get_server
@status << "Preset server: <a href='/servers/edit/#{server.id}' title='#{server.mods.map{|e| e.name}.join(", ")}'>#{server.to_label}"
end
end
end
if setting
setting.beta = @beta unless @beta.nil?
setting.server = @server_bool unless @server_bool.nil?
@status << "Override settings profile: <a href='/appsettings/edit/#{setting.id}' title='#{setting.class.short}: #{setting.real_exe} #{setting.real_params} (#{setting.real_path})'>#{setting.label}</a>"
else
if preset.appsetting
setting = preset.appsetting
setting.beta = @beta unless @beta.nil?
setting.server = @server_bool unless @server_bool.nil?
@status << "Preset settings profile: <a href='/appsettings/edit/#{setting.id}' title='#{setting.class.short}: #{setting.real_exe} #{setting.real_params} (#{setting.real_path})'>#{setting.label}</a>"
end
end
setting = Arma2Appsetting.new(:beta => @beta, :server => @server_bool) if setting.nil?
@setting_used = setting
if setting.real_path
unless File.directory?(setting.real_path)
@error << "<b>WARNING:</b> ArmA folder not set or non existent: #{setting.real_path}"
end
else
@error << "<b>WARNING:</b> ArmA folder not set or non existent: #{setting.real_path}"
end
if setting.modpath
unless File.directory?(setting.real_modpath)
@error << "<b>WARNING:</b> Mod installation folder not set or non existent: #{setting.real_modpath}"
end
end
if action
@status << "Override action: <a href='/actions/edit/#{action.id}' title='#{action.tasks.join(",") if action.tasks.is_a?(Array)}'>#{action.name}</a>"
else
if preset.action
action = preset.action
@status << "Preset action: #{action.name}"
end
end
case params["commit"].downcase
when "edit preset"
redirect_to "/sixconfigs/edit/#{preset.id}"
return
when "edit server"
redirect_to "/queryservers/edit/#{queryserver.id}"
return
when "edit action"
redirect_to "/actions/edit/#{action.id}"
return
when "edit setting"
redirect_to "/appsettings/edit/#{setting.id}"
return
when "edit userconfig"
redirect_to "/config/?setting=#{setting.id}"
return
end
@msg << "Skip status reset!" if reset
@procs = setting.processes
@mods = preset.all_mods(server, setting)
@mods.each do |mod|
mod.process(setting, reset, @autoskip, @force)
case mod.status(setting)
when :special
@special << mod
when :disabled
@disabled << mod
when :skip
@skip << mod
when :check
@check << mod
when :install
@install << mod
else
logger.debug "Warning; weird mod status: #{mod.status(setting)}"
end
end
@skip.sort! { |a, b| a.name <=> b.name }
@check.sort! { |a, b| a.name <=> b.name }
@install.sort! { |a, b| a.name <=> b.name }
@disabled.sort! { |a, b| a.name <=> b.name }
case params["commit"].downcase
when "update_gamespy"
gslist_installed = begin
%x[gslist -h]
$?.exitstatus == 0
rescue
false
end
if gslist_installed
@msg << "<b>A window should open displaying the gamespy progress</b>"
if gs_geo
@system_setting.update_gamespy(setting) else
@system_setting.update_gamespy_nogeo(setting) end
else
@error << "<b>ERROR: gslist tool is missing!</b>"
@error << "Please download from <a href=\"http://six.dev-heaven.net/wagn/Six_Updater_Suite+download+gslist\" target=\"_blank\">Six Updater Wagn</a>, and put in #{SixUpdaterWeb::TOOL_PATH}"
end
when "server mod check"
if queryserver
queryserver.latest
queryserver.save if queryserver.changed?
@server_check = true
@signatures = queryserver.signatures
@allowed, @disallowed, @garbage = *setting.allowance(@signatures)
else
@error << "No server selected!"
end
when "save"
unless queryserver.nil?
queryserver.latest
queryserver.save if queryserver.changed?
end
preset.output_yml(setting, server)
@msg << "Saved six-updater.yml!"
when "execute"
unless queryserver.nil?
queryserver.latest
queryserver.save if queryserver.changed?
end
preset.execute(action, setting, server, @autoskip, @inweb)
if @inweb
sleep 1
redirect_to :action => 'logoutput'
return
end
@msg << "Saved six-updater.yml!"
@msg << "<b>A window should open displaying the update process progress</b>"
when "speedtest"
@system_setting.speedtest
@msg << "<b>A window should open displaying the speedtest progress</b>"
when "open armafolder"
setting.explore
@msg << "Explorer should open"
when "stop game"
setting.kill!.each { |entry| @msg << "Process killed: #{entry}" }
sleep 1
when "read mods"
Mod.read_modfolders(setting)
end
act(setting, preset, action, server)
end
|