diff --git a/perl-xCAT/xCAT/InstUtils.pm b/perl-xCAT/xCAT/InstUtils.pm index 733888816..8ef01d3b7 100644 --- a/perl-xCAT/xCAT/InstUtils.pm +++ b/perl-xCAT/xCAT/InstUtils.pm @@ -978,6 +978,7 @@ sub dolitesetup if ( ! -d "$instrootloc/.default" ) { my $mcmd = qq~/bin/mkdir -m 644 -p $instrootloc/.default ~; my $output = xCAT::Utils->runcmd("$mcmd", -1); + if ($::RUNCMD_RC != 0) { my $rsp; push @{$rsp->{data}}, "Could not create $instrootloc/.default.\n"; @@ -989,6 +990,7 @@ sub dolitesetup if ( ! -d "$instrootloc/.statelite" ) { my $mcmd = qq~/bin/mkdir -m 644 -p $instrootloc/.statelite ~; my $output = xCAT::Utils->runcmd("$mcmd", -1); + if ($::RUNCMD_RC != 0) { my $rsp; push @{$rsp->{data}}, "Could not create $instrootloc/.statelite.\n"; @@ -1003,6 +1005,41 @@ sub dolitesetup # read the litefile and try to copy into $default # everything in the litefile command output should be processed + foreach my $line (@litefiles) { + # $file could be full path file name or dir name + # ex. /foo/bar/ or /etc/lppcfg + my ($node, $option, $file) = split (/\|/, $line); + + # ex. .../inst_root/foo/bar/ or .../inst_root/etc/lppcfg + my $instrootfile = $instrootloc . $file; + + # there's one scenario to be handled firstly + # in litefile table, there's one entry: /path/to/file, which is one file + # however, there's already one directory named "/path/to/file/" + # + # Or: + # the entry in litefile is "/path/to/file/", which is one directory + # however, there's already one file named "/path/to/file" + # + # in these cases, + # need to indicate the user there's already one existing file/directory in the spot + # then, exit + + if ($file =~ m/\/$/ and -f $instrootfile) { + my $rsp; + push @{$rsp->{data}}, qq{there is already one file named "$file", but the entry in litefile table is set to one directory, please check it}; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + if ($file !~ m/\/$/ and -d $instrootfile) { + my $rsp; + push @{$rsp->{data}}, qq{there is already one directory named "$file", but the entry in litefile table is set to one file, please check it}; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + } + + my @copiedfiles; foreach my $line (@litefiles) { diff --git a/xCAT-server/lib/xcat/plugins/aixinstall.pm b/xCAT-server/lib/xcat/plugins/aixinstall.pm index a253b121d..9f5580c79 100644 --- a/xCAT-server/lib/xcat/plugins/aixinstall.pm +++ b/xCAT-server/lib/xcat/plugins/aixinstall.pm @@ -5696,6 +5696,12 @@ sub updatespot # if this has a shared_root resource then # it might need statelite setup my $rc=xCAT::InstUtils->dolitesetup($image, \%imghash, \@nodelist, $callback, $subreq); + if ($rc eq 1) { # error + my $rsp; + push @{$rsp->{data}}, qq{There's one error when doing statelite setup, see the error message above}; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } } # Modify the rc.dd-boot script diff --git a/xCAT/postscripts/aixlitesetup b/xCAT/postscripts/aixlitesetup index bec566e2c..117c853ea 100644 --- a/xCAT/postscripts/aixlitesetup +++ b/xCAT/postscripts/aixlitesetup @@ -256,11 +256,22 @@ FindFile () { SRC=`echo ${MOUNTDIR}/${SERVER}${DIR}${path} | sed -e 's/\/\//\//'` # ex. /.statelite/mnt/10.2.0.200/etc/FScfg + # ex. /.statelite/mnt/10.2.0.200/root/ssh/ if [ -e ${SRC} ]; then + PATHEND=`expr ${#path} - 1` # get the last char of the path + if [ ${path[${PATHEND}]} -ne '/' ] && [ -d ${SRC} ]; then + FOUND=0 + continue + fi - FOUND=1 - ProcessType ${SRC} ${path} ${type} ${isChild} - break + if [ ${path[${PATHEND}]} -eq "/" ] && [ -f ${SRC} ]; then + FOUND=0 + continue + fi + + FOUND=1 + ProcessType ${SRC} ${path} ${type} ${isChild} + break fi done