Mailinglist Archive: yast-commit (590 mails)

< Previous Next >
[yast-commit] r61623 - in /trunk/ntp-client/src: NtpClient.ycp dialogs.ycp widgets.ycp
  • From: varkoly@xxxxxxxxxxxxxxxx
  • Date: Thu, 08 Apr 2010 14:56:04 -0000
  • Message-id: <E1Nzt9I-0004qk-Qv@xxxxxxxxxxxxxxxx>
Author: varkoly
Date: Thu Apr 8 16:56:04 2010
New Revision: 61623

URL: http://svn.opensuse.org/viewcvs/yast?rev=61623&view=rev
Log:
Initial version of time synchronization without running ntp as deamon

Modified:
trunk/ntp-client/src/NtpClient.ycp
trunk/ntp-client/src/dialogs.ycp
trunk/ntp-client/src/widgets.ycp

Modified: trunk/ntp-client/src/NtpClient.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ntp-client/src/NtpClient.ycp?rev=61623&r1=61622&r2=61623&view=diff
==============================================================================
--- trunk/ntp-client/src/NtpClient.ycp (original)
+++ trunk/ntp-client/src/NtpClient.ycp Thu Apr 8 16:56:04 2010
@@ -65,6 +65,21 @@
global boolean run_service = true;

/**
+ * Should the time synchronized periodicaly?
+ */
+global boolean synchronize_time = false;
+
+/**
+ * The interval of synchronization in minutes.
+ */
+global integer sync_interval = 5;
+
+/**
+ * The cron file name for the synchronization.
+ */
+global string cron_file = "/etc/cron.d/novell.ntp-synchronize";
+
+/**
* Service name of the NTP daemon
*/
global string service_name = "ntp";
@@ -503,6 +518,15 @@
if (! Mode::commandline() && ! FileChanges::CheckFiles (["/etc/ntp.conf"]))
failed = true;
ProcessNtpConf();
+ list crontab = (list)SCR::Read(.cron, cron_file, "");
+ y2milestone("CRONTAB %1", crontab);
+ string tmp = (string) crontab[0,"events",0,"active"]:"0";
+ synchronize_time = tmp == "1";
+ tmp = (string) crontab[0,"events",0,"minute"]:"*/5";
+ y2milestone("MINUTE %1", tmp);
+ tmp = regexpsub(tmp,"\\*/","");
+ sync_interval = tointeger(tmp);
+ y2milestone("SYNC_INTERVAL %1", sync_interval);

string run_chroot_s = (string) SCR::Read
(.sysconfig.ntp.NTPD_RUN_CHROOTED);
run_chroot = run_chroot_s == "yes";
@@ -799,6 +823,14 @@
{
Service::RunInitScript(service_name, "stop");
}
+ if (synchronize_time)
+ {
+ SCR::Write (.target.string,cron_file,"-*/"+sync_interval+" * * * * root
/etc/init.d/ntp ntptimeset &>/dev/null");
+ }
+ else
+ {
+ SCR::Execute (.target.bash,"test -e "+cron_file+" && rm
"+cron_file+";");
+ }

sleep(sl);

@@ -821,6 +853,8 @@
* @return boolean True on success
*/
global define boolean Import (map settings) ``{
+ synchronize_time = settings["synchronize_time"]:false;
+ sync_interval = settings["sync_interval"]:5;
run_service = settings["start_at_boot"]:false;
run_chroot = settings["start_in_chroot"]:true;
// compatibility: configure_dhcp:true translates to ntp_policy:auto
@@ -850,10 +884,12 @@
*/
global define map Export () ``{
return $[
- "start_at_boot" : run_service,
- "start_in_chroot" : run_chroot,
- "ntp_policy" : ntp_policy,
- "peers" : ntp_records,
+ "synchronize_time" : synchronize_time,
+ "sync_interval" : sync_interval,
+ "start_at_boot" : run_service,
+ "start_in_chroot" : run_chroot,
+ "ntp_policy" : ntp_policy,
+ "peers" : ntp_records,
];
}


Modified: trunk/ntp-client/src/dialogs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ntp-client/src/dialogs.ycp?rev=61623&r1=61622&r2=61623&view=diff
==============================================================================
--- trunk/ntp-client/src/dialogs.ycp (original)
+++ trunk/ntp-client/src/dialogs.ycp Thu Apr 8 16:56:04 2010
@@ -86,7 +86,7 @@
define symbol SimpleDialog () ``{
NtpClient::simple_dialog = true;

- list<map<string,any> > w = CWM::CreateWidgets (["start", "server_address",
"use_random_servers", "complex_button"],
+ list<map<string,any> > w = CWM::CreateWidgets (["start", "interval",
"server_address", "use_random_servers", "complex_button"],
GetWidgets ());
term contents = `HBox (`HSpacing (1), `VBox (
`VStretch (),
@@ -96,6 +96,8 @@
`HStretch ()
),
`VStretch (),
+ "interval",
+ `VStretch (),
`HBox (
`HStretch (),
`Frame (
@@ -155,6 +157,8 @@
"policy_combo",
"custom_policy"
),
+ `VSpacing(),
+ "interval",
`VSpacing()
)
),
@@ -185,7 +189,7 @@
"general" : $[
"header" : _("General Settings"),
"contents" : tab1,
- "widget_names" : ["start", "policy_combo", "custom_policy",
"overview"],
+ "widget_names" : ["start", "policy_combo", "custom_policy",
"interval", "overview"],
],
"security" : $[
"header" : _("Security Settings"),

Modified: trunk/ntp-client/src/widgets.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ntp-client/src/widgets.ycp?rev=61623&r1=61622&r2=61623&view=diff
==============================================================================
--- trunk/ntp-client/src/widgets.ycp (original)
+++ trunk/ntp-client/src/widgets.ycp Thu Apr 8 16:56:04 2010
@@ -74,21 +74,62 @@
*/
define symbol ntpEnabledOrDisabled (string id, map event) ``{
any ev_id = event["ID"]:nil;
- if (ev_id == "boot" || ev_id == "never")
+ if (ev_id == "boot" || ev_id == "never" || ev_id == "sync" )
{
- boolean enabled = UI::QueryWidget (`id ("start"), `CurrentButton)
- != "never";
+ boolean enabled = UI::QueryWidget (`id ("start"), `CurrentButton) !=
"never";
UI::ChangeWidget (`id (id), `Enabled, enabled);
}
}

/**
+ * Handle function of the widget
+ * @param id string widget id
+ * @param event map event that caused storing process
+ * @return symbol always nil
+ */
+define symbol timeSyncOrNo (string id, map event) ``{
+ any ev_id = event["ID"]:nil;
+ if (ev_id == "boot" || ev_id == "never" || ev_id == "sync" )
+ {
+ boolean enabled = UI::QueryWidget (`id ("start"), `CurrentButton) ==
"sync";
+ UI::ChangeWidget (`id (id), `Enabled, enabled);
+ }
+}
+
+/**
+ * Initialize the widget
+ * @param id any widget id
+ */
+define void intervalInit (string id) ``{
+ UI::ChangeWidget (`id ("interval"), `Value, NtpClient::sync_interval);
+}
+
+/**
+ * Store settings of the widget
+ * @param id any widget id
+ * @param event map event that caused storing process
+ */
+define void intervalStore (string id, map event) ``{
+ NtpClient::sync_interval = (integer)UI::QueryWidget (`id
("interval"), `Value);
+}
+
+/**
* Initialize the widget
* @param id any widget id
*/
define void startInit (string id) ``{
- UI::ChangeWidget (`id ("start"), `CurrentButton,
- NtpClient::run_service ? "boot" : "never");
+ if( NtpClient::synchronize_time )
+ {
+ UI::ChangeWidget (`id ("start"), `CurrentButton, "sync");
+ }
+ else if( NtpClient::run_service )
+ {
+ UI::ChangeWidget (`id ("start"), `CurrentButton, "boot");
+ }
+ else
+ {
+ UI::ChangeWidget (`id ("start"), `CurrentButton, "never");
+ }
}

/**
@@ -97,7 +138,8 @@
* @param event map event that caused storing process
*/
define void startStore (string id, map event) ``{
- NtpClient::run_service = UI::QueryWidget (`id ("start"), `CurrentButton)
== "boot";
+ NtpClient::run_service = UI::QueryWidget (`id ("start"),
`CurrentButton) == "boot";
+ NtpClient::synchronize_time = UI::QueryWidget (`id ("start"),
`CurrentButton) == "sync";
}

/**
@@ -384,7 +426,7 @@
} else {
// Random servers function is disabled
UI::ChangeWidget(`id ("use_random_servers"), `Value, false);
- if (NtpClient::run_service) {
+ if (NtpClient::run_service || NtpClient::synchronize_time) {
UI::ChangeWidget(`id ("server_address"), `Enabled, true);
UI::ChangeWidget(`id (`select_server), `Enabled, true);
} else {
@@ -503,7 +545,7 @@
}
NtpClient::modified = true;
any ev_id = event["ID"]:nil;
- if (ev_id == "boot" || ev_id == "never" || ev_id == "policy_combo")
+ if (ev_id == "boot" || ev_id == "never" || ev_id == "sync" || ev_id ==
"policy_combo" )
{
symbol pol = (symbol)UI::QueryWidget (`id ("policy_combo"), `Value);

@@ -1219,6 +1261,16 @@
"handle_events" : [ "fudge_button" ],
"handle" : fudgeButtonHandle,
],
+ "interval" : $[
+ "widget" : `intfield,
+ "label" : _("&Interval of the Synchronization in Minutes"),
+ "minimum" : 1,
+ "maximum" : 60,
+ "init" : intervalInit,
+ "store" : intervalStore,
+ "help" : HELPS["start"]:"",
+ "handle" : timeSyncOrNo,
+ ],
"start" : $[
"widget" : `radio_buttons,
// frame
@@ -1227,13 +1279,15 @@
// radio button
[ "never", _("Only &Manually") ],
// radio button
+ [ "sync", _("&Synchronize without Daemon") ],
+ // radio button
[ "boot", _("Now and On &Boot") ],
],
"help" : HELPS["start"]:"",
"init" : startInit,
"store" : startStore,
"handle" : startHandle,
- "handle_events" : [ "boot", "never" ],
+ "handle_events" : [ "boot", "never","sync" ],
"opt" : [`notify],
],
"run_chroot" : $[

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages