ACC SHELL

Path : /usr/share/YaST2/clients/
File Upload :
Current File : //usr/share/YaST2/clients/ntp-client_finish.ycp

/**
 * File:	clients/ntp-client_finish.ycp
 * Summary:	Installation client for writing ntp configuration 
 *		at the end of 1st stage
 * Author:	Bubli <kmachalkova@suse.cz>
 *
 */
{
textdomain "ntp-client";

import "NtpClient";

any ret = nil;
string func = "";
map param = $[];

/* Check arguments */
if(size(WFM::Args()) > 0 && is(WFM::Args(0), string)) {
    func = (string)WFM::Args(0);
    if(size(WFM::Args()) > 1 && is(WFM::Args(1), map))
	param = (map)WFM::Args(1);
}

y2milestone ("starting ntp-client_finish");
y2debug("func=%1", func);
y2debug("param=%1", param);

if (func == "Info")
{
    return (any)$[
	"steps" : 1,
	// progress step title
	"title" : _("Writing NTP Configuration..."),
	"when" : NtpClient::modified ? [ `installation,  `autoinst ] : [],
    ];
}
else if (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)
    list<string> ss = NtpClient::GetUsedNtpServers();

    // ntp.conf from the RPM
    NtpClient::ProcessNtpConf();

    // put users server(s) back
    foreach (string server, ss, {
	// if not present, it adds it,
	// otherwise it preserves what is there. uff what an API
	integer idx = NtpClient::findSyncRecord("server", server); // -1: new
	NtpClient::selectSyncRecord(idx);
	NtpClient::selected_record["address"] = server;
	NtpClient::selected_record["type"] = "server";
	// bnc#450418, add a recommended option
	NtpClient::enableOptionInSyncRecord ("iburst");
	NtpClient::storeSyncRecord();
    });

    NtpClient::write_only = true;

    NtpClient::Write();

}
else
{
    y2error ("unknown function: %1", func);
    ret = nil;
}

y2debug("ret=%1", ret);
y2milestone("ntp-client_finish finished");
return ret;

}

ACC SHELL 2018