7 use lib "@PERLLIBDIR@";
8 use NTP::Util qw(ntp_read_vars);
10 exit run(@ARGV) unless caller;
14 if (!processOptions(\@_, $opts)) {
18 my $tries = $opts->{tries}; # How many tries before we give up? (10 min+)
19 my $sleep = $opts->{sleep}; # Seconds to sleep between tries (6s = 10/min)
20 my $verbose = $opts->{verbose}; # Be verbose?
25 print "Waiting for ntpd to synchronize... " if $verbose;
27 for my $i (1 .. $tries) {
28 my $info = ntp_read_vars(0, []);
31 print "\bntpd is not running!\n" if $verbose;
35 if (!exists $info->{status_line}{leap}) {
36 print "\bLeap status not available\n";
40 my $leap = $info->{status_line}{leap};
41 my $sync = $info->{status_line}{sync};
43 if ($leap =~ /(sync|leap)_alarm/) {
44 print "\b".(substr "*+:.", $i % 4, 1) if $verbose;
45 sleep $sleep if $i < $tries;
49 if ($leap =~ /leap_(none|((add|del)_sec))/) {
50 # We could check $sync here to make sure we like the source...
51 print "\bOK!\n" if $verbose;
55 print "\bUnexpected 'leap' status <$leap>\n";
59 print "\bNo!\nntpd did not synchronize.\n" if $verbose;