]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
NTP servers: Work around Debian's failure to honour preseed
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 17 Feb 2015 17:35:57 +0000 (17:35 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 17 Feb 2015 17:45:52 +0000 (17:45 +0000)
Setting clock-setup/ntp-server is not sufficient: it only takes effect
in the installer (!)

I have reported this as Debian #778564.  In the meantime we should
work around it for current releases (including jessie, which is
frozen).

For later releases, the new ntp.conf editing code arranges to bomb out
if we have an NTP server configured and find it hasn't been honoured
during the install.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
ts-host-install

index ae1d228ae644be0f1841eafa3a12727571a1366a..9656079c92473f4ab2bdf1688c4888faa4931f3a 100755 (executable)
@@ -119,6 +119,26 @@ END
 
     target_install_packages($ho, qw(ed));
 
+    my $ntpserver = get_target_property($ho, 'NtpServer');
+    if ($ntpserver) {
+       target_editfile_root($ho, '/etc/ntp.conf', sub {
+           my $done= 0;
+           while (<EI>) {
+               if (m/^server\s/) {
+                   if ($ho->{Suite} =~ m/lenny|squeeze|wheezy|jessie/) {
+                       $_= $done ? "" : "server $ntpserver\n";
+                   } else {
+                       m/^server \Q$ntpserver\E\s/ or
+                           die "NTP server not honoured, Debian #778564 ";
+                   }
+                   $done= 1;
+               }
+               print EO or die $!;
+           }
+           $done or die;
+       });
+    }
+
     target_cmd_root($ho, "update-rc.d osstest-confirm-booted start 99 2 .");
 
     logm('OK: install completed');