Commit 564afc52 authored by Robert Ricci's avatar Robert Ricci

Run ntpdate before ntpd, so that we start with the correct time.

parent 4e4bee51
......@@ -26,6 +26,7 @@ BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
sub fatal($);
sub ntpstart();
sub ntpdate();
#
# Turn off line buffering on output
......@@ -45,6 +46,7 @@ my $newfile = "/tmp/ntp.conf.new";
my $ntpfile = "/etc/ntp.conf";
my $driftfile = "/etc/ntp.drift";
my $pidfile = "/var/run/ntpd.pid";
my $ntpdate = "/usr/sbin/ntpdate";
my $debug = 0;
#
......@@ -59,6 +61,37 @@ sub ntpstart () {
return ($? >> 8);
}
#
# Run ntpdate to get the time set correctly before starting ntpd
#
sub ntpdate() {
#
# We need to give -b to set time directly (instead of using adjtime()), and
# give the boss node's name
#
my ($bossname) = split(" ", `tmcc bossinfo`);
my $ntpcmd = "$ntpdate -b -s ";
if (REMOTE()) {
$ntpcmd .= "-t 5 ";
}
$ntpcmd .= "$bossname";
if ($debug) {
print "$ntpcmd\n";
return 0;
}
system("$ntpcmd");
return ($? >> 8);
}
#
# First, run ntpdate so that we start out with the time set correctly. If
# it fails, we just warn about it, and let things continue anyway
#
if (ntpdate()) {
warn "WARNING: ntpdate failed!\n";
}
#
# Ask for setup. If none then we are done. If provided with a drift value
# but no servers/peers, then need to leave the config alone and just
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment