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