Changeset 1714 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Mar 10, 2013, 6:17:47 PM (11 years ago)
Author:
Bruno Cornec
Message:
  • remove param vmntpcmd and use oscmdntp instead placed in pb.conf
  • Improve ntp handling for setupvm by adding a call to date when ntpdate is failing
  • Update appropriate docs
  • Fix pb_get_sudocmds which was using @_ directly which was impacting parameters in the calling function, and removed e.g. the ntp server name from the cmd line !
  • TODO: if a ntpd server is running, avoid doing all ntp/date stuff
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1712 r1714  
    19151915    my $tmout = undef;
    19161916    my $path = undef;
     1917
    19171918    if ($cmt =~ /^VM/) {
    19181919        $login = "vmlogin";
     
    27462747my $nontp = shift || 0;
    27472748
     2749pb_log(1,"Entering pb_date2v\n");
    27482750# VE gets time from parent OS.
    27492751return "/bin/true" if ($vtype) =~ /^ve/o;
    27502752
    27512753my ($ntp) = pb_conf_get_if($vtype."ntp");
    2752 my $vntp = $ntp->{$ENV{'PBPROJ'}} if (defined $ntp);
     2754my $vntp = undef;
    27532755my $ntpline = undef;
     2756$vntp = $ntp->{$ENV{'PBPROJ'}} if (defined $ntp);
    27542757
    27552758if ((defined $vntp) && ($vntp !~ /^\s*$/)) {
     2759    pb_log(2,"ntp server is $vntp\n");
    27562760    # ntp command depends on pbos
    2757     my $vntpcmd = pb_distro_get_param($pbos,pb_conf_get($vtype."ntpcmd"));
     2761    my $vntpcmd = pb_distro_get_param($pbos,pb_conf_get("oscmdntp"));
    27582762    $ntpline = "sudo $vntpcmd $vntp";
    27592763}
     
    27652769my $dateline = "sudo /bin/date $upddate";
    27662770if ((defined $ntpline) && ($nontp == 0)) {
     2771    pb_log(1,"pb_date2v returns $ntpline\n");
    27672772    return($ntpline);
    27682773} else {
     2774    pb_log(1,"pb_date2v returns $dateline\n");
    27692775    return($dateline);
    27702776}
     
    34083414print PBOUT "$pbac->{$ENV{'PBPROJ'}}   ALL=(ALL) NOPASSWD:ALL\n";
    34093415EOF
    3410 }
     3416    }
    34113417    print SCRIPT << 'EOF';
    34123418close(PBOUT);
     
    34193425        # Sync date
    34203426        # do it after sudoers is setup
    3421         print SCRIPT "pb_system(\"$ntpline\",\"Updating time with $ntpline\",\"mayfail\");\n";
     3427        print SCRIPT "my \$res = pb_system(\"$ntpline\",\"Updating time with $ntpline\",\"mayfailverbose\");\n";
     3428        print SCRIPT "if (\$res != 0) {\n";
     3429        # try again with another method
     3430        $ntpline = pb_date2v($vtype,$pbos,1);
     3431        print SCRIPT "  pb_system(\"$ntpline\",\"Updating time with $ntpline\",\"mayfailverbose\");\n";
     3432        print SCRIPT "}\n";
    34223433    }
    34233434
     
    43824393       
    43834394my $pbos = shift;
     4395my @cmds = @_;
    43844396my %sudocmds;
    43854397
    4386 pb_log(2,"pb_get_sudocmds entering with lines:".Dumper(@_)."\n");
    4387 foreach my $c (split(/;/,$pbos->{'update'}),split(/;/,$pbos->{'install'}),@_) {
     4398pb_log(2,"pb_get_sudocmds entering with lines:".Dumper(@cmds)."\n");
     4399foreach my $c (split(/;/,$pbos->{'update'}),split(/;/,$pbos->{'install'}),@cmds) {
    43884400    pb_log(2,"pb_get_sudocmds analyses $c\n");
    43894401    next if ($c !~ /^\s*sudo/);
Note: See TracChangeset for help on using the changeset viewer.