/
ntp-client_finish.rb
73 lines (59 loc) · 1.92 KB
/
ntp-client_finish.rb
1
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
# encoding: utf-8
# File: clients/ntp-client_finish.ycp
# Summary: Installation client for writing ntp configuration
# at the end of 1st stage
# Author: Bubli <kmachalkova@suse.cz>
#
module Yast
class NtpClientFinishClient < Client
def main
textdomain "ntp-client"
Yast.import "NtpClient"
@ret = nil
@func = ""
@param = {}
# Check arguments
if Ops.greater_than(Builtins.size(WFM.Args), 0) &&
Ops.is_string?(WFM.Args(0))
@func = Convert.to_string(WFM.Args(0))
if Ops.greater_than(Builtins.size(WFM.Args), 1) &&
Ops.is_map?(WFM.Args(1))
@param = Convert.to_map(WFM.Args(1))
end
end
Builtins.y2milestone("starting ntp-client_finish")
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)
if @func == "Info"
return {
"steps" => 1,
# progress step title
"title" => _("Writing NTP Configuration..."),
"when" => NtpClient.modified ? [:installation, :autoinst] : []
}
elsif @func == "Write"
# bnc#449615, must merge the configs which Export/Import fails to do.
# User config from installation time:
# fortunately so far we only have the server address(es)
pools = NtpClient.ntp_conf.pools
# ntp.conf from the RPM
NtpClient.config_has_been_read = false
NtpClient.ProcessNtpConf
# put users server(s) back
NtpClient.ntp_conf.clear_pools
pools.each_pair do |server, options|
NtpClient.ntp_conf.add_pool(server, options)
end
NtpClient.write_only = true
NtpClient.Write
else
Builtins.y2error("unknown function: %1", @func)
@ret = nil
end
Builtins.y2debug("ret=%1", @ret)
Builtins.y2milestone("ntp-client_finish finished")
deep_copy(@ret)
end
end
end
Yast::NtpClientFinishClient.new.main