diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 028515366..c256a448c 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1989,12 +1989,41 @@ sub mksysclone } my $cmd =qq{echo "$node:compute:$imagename:" >> $clusterfile}; - my $out = xCAT::Utils->runcmd($cmd, -1); + my $rc = xCAT::Utils->runcmd($cmd, -1); + + my $imagedir; + my $osimagetab = xCAT::Table->new('linuximage'); + my $osimageentry = $osimagetab->getAttribs({imagename => $imagename}, 'rootimgdir'); + if($osimageentry){ + $imagedir = $osimageentry->{rootimgdir}; + $imagedir =~ s/^(\/.*)\/.+\/?$/$1/; + }else{ + $imagedir = "$installroot/sysclone/images"; + $cmd = "chdef -t osimage $imagename rootimgdir=$imagedir/$imagename"; + $rc = `$cmd`; + } + + my $cfgimagedir = `cat /etc/systemimager/rsync_stubs/40$imagename|grep path`; + chomp($cfgimagedir); + $cfgimagedir =~ s/^\s+path=(\/.*)\/.+$/$1/g; + + if($imagedir ne $cfgimagedir){ + my $oldstr = `cat /etc/systemimager/rsync_stubs/40$imagename|grep path`; + chomp($oldstr); + $oldstr =~ s/\//\\\\\//g; - unless (-r "$installroot/sysclone/images/$imagename/opt/xcat/xcatdsklspost") + my $targetstr="\tpath=".$imagedir."/".$imagename; + $targetstr =~ s/\//\\\\\//g; + $cmd= "sed -i \"s/$oldstr/$targetstr/\" /etc/systemimager/rsync_stubs/40$imagename"; + $rc = `$cmd`; + } + + $rc = `export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_mkrsyncd_conf`; + + unless (-r "$imagedir/$imagename/opt/xcat/xcatdsklspost") { - mkpath("$installroot/sysclone/images/$imagename/opt/xcat/"); - copy("$installroot/postscripts/xcatdsklspost","$installroot/sysclone/images/$imagename/opt/xcat/"); + mkpath("$imagedir/$imagename/opt/xcat/"); + copy("$installroot/postscripts/xcatdsklspost","$imagedir/$imagename/opt/xcat/"); } }