2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 17:46:38 +00:00

Merge pull request #702 from cxhong/addkit

Remove /tmp/tmpkit dir after addkit and extract kit tar file only once
This commit is contained in:
Victor Hu 2016-02-10 20:35:51 -05:00
commit 0b71037582

View File

@ -104,6 +104,7 @@ sub process_request
$rc = lskit($request, $callback, $request_command);
} elsif ($command eq "addkit"){
$rc = addkit($request, $callback, $request_command);
system("rm -rf /tmp/tmpkit/");
} elsif ($command eq "rmkit"){
$rc = rmkit($request, $callback, $request_command);
} elsif ($command eq "lskitcomp"){
@ -1246,12 +1247,10 @@ sub addkit
if($::VERBOSE){
my %rsp;
push@{ $rsp{data} }, "Extract Kit $kit to /tmp";
push@{ $rsp{data} }, "Extract Kit $kit to /tmp/tmpkit";
xCAT::MsgUtils->message( "I", \%rsp, $callback );
$rc = system("tar jxvf $kit -C /tmp/tmpkit/ --wildcards */kit.conf");
} else {
$rc = system("tar jxf $kit -C /tmp/tmpkit/ --wildcards */kit.conf");
}
$rc = system("tar jxvf $kit -C /tmp/tmpkit/");
opendir($dir,"/tmp/tmpkit/");
my @files = readdir($dir);
@ -1312,40 +1311,6 @@ sub addkit
return 1;
}
if( !-d "$kit") {
# should be a tar.bz2 file
system("rm -rf /tmp/tmpkit/");
mkpath("/tmp/tmpkit/");
if($::VERBOSE){
my %rsp;
push@{ $rsp{data} }, "Extract Kit $kit to /tmp";
xCAT::MsgUtils->message( "I", \%rsp, $callback );
$rc = system("tar jxvf $kit -C /tmp/tmpkit/");
} else {
$rc = system("tar jxf $kit -C /tmp/tmpkit/");
}
opendir($dir,"/tmp/tmpkit/");
my @files = readdir($dir);
foreach my $file ( @files ) {
next if ( $file eq '.' || $file eq '..' );
$kittmpdir = "/tmp/tmpkit/$file";
last;
}
if ( !$kittmpdir ) {
my %rsp;
push@{ $rsp{data} }, "Could not find extracted kit in /tmp/tmpkit";
xCAT::MsgUtils->message( "E", \%rsp, $callback );
return 1;
}
}
my %rsp;
push@{ $rsp{data} }, "Adding Kit $kithash->{kitname}";
xCAT::MsgUtils->message( "I", \%rsp, $callback );