mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 03:12:30 +00:00 
			
		
		
		
	fix issue 5633, enhance check tftp service (#5639)
* fix issue 5633, enhance check tftp service
This commit is contained in:
		| @@ -369,20 +369,22 @@ sub is_tftp_ready { | ||||
|     my $mnip = shift; | ||||
|     $mnip = shift if (($mnip) && ($mnip =~ /probe_utils/)); | ||||
|     my $tftpdir = shift; | ||||
|     my $test_dir = $tftpdir . "/tftptest/"; | ||||
|     system("mkdir -p $test_dir"); | ||||
|  | ||||
|     rename("/$tftpdir/tftptestt.tmp", "/$tftpdir/tftptestt.tmp.old") if (-e "/$tftpdir/tftptestt.tmp"); | ||||
|     rename("/$test_dir/tftptestt.tmp", "/$test_dir/tftptestt.tmp.old") if (-e "/$test_dir/tftptestt.tmp"); | ||||
|     rename("./tftptestt.tmp", "./tftptestt.tmp.old") if (-e "./tftptestt.tmp"); | ||||
|  | ||||
|     system("touch /$tftpdir/tftptestt.tmp"); | ||||
|     my $output = `tftp -4 -v $mnip  -c get tftptestt.tmp`; | ||||
|     system("touch /$test_dir/tftptestt.tmp"); | ||||
|     my $output = `tftp -4 -v $mnip -c get /tftptest/tftptestt.tmp 2>&1`; | ||||
|     if ((!$?) && (-e "./tftptestt.tmp")) { | ||||
|         unlink("./tftptestt.tmp"); | ||||
|         rename("./tftptestt.tmp.old", "./tftptestt.tmp") if (-e "./tftptestt.tmp.old"); | ||||
|         rename("/$tftpdir/tftptestt.tmp.old", "/$tftpdir/tftptestt.tmp") if (-e "/$tftpdir/tftptestt.tmp.old"); | ||||
|         rename("/$test_dir/tftptestt.tmp.old", "/$test_dir/tftptestt.tmp") if (-e "/$test_dir/tftptestt.tmp.old"); | ||||
|         return 1; | ||||
|     } else { | ||||
|         rename("./tftptestt.tmp.old", "./tftptestt.tmp") if (-e "./tftptestt.tmp.old"); | ||||
|         rename("/$tftpdir/tftptestt.tmp.old", "/$tftpdir/tftptestt.tmp") if (-e "/$tftpdir/tftptestt.tmp.old"); | ||||
|         rename("/$test_dir/tftptestt.tmp.old", "/$test_dir/tftptestt.tmp") if (-e "/$test_dir/tftptestt.tmp.old"); | ||||
|         return 0; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -102,8 +102,9 @@ sub do_main_job { | ||||
|     $rc |= $rst; | ||||
|  | ||||
|     #check tftp service | ||||
|     $rst = check_tftp_service($installnicip, \$checkpoint, \@error); | ||||
|     print_check_result($checkpoint, "f", $rst, \@error); | ||||
|     ($rst, $flag) = check_tftp_service($installnicip, \$checkpoint, \@error); | ||||
|     print_check_result($checkpoint, $flag, $rst, \@error); | ||||
|     $rst = 0 if ($flag == "w"); | ||||
|     $rc |= $rst; | ||||
|  | ||||
|     #check DNS service | ||||
| @@ -696,6 +697,7 @@ sub check_tftp_service { | ||||
|     my $checkpoint_ref =  shift; | ||||
|     my $error_ref = shift; | ||||
|     my $rst       = 1; | ||||
|     my $flag      = 'f'; | ||||
|  | ||||
|     $$checkpoint_ref = "Checking TFTP service is configured..."; | ||||
|     @$error_ref = (); | ||||
| @@ -726,10 +728,17 @@ sub check_tftp_service { | ||||
|                     push @$error_ref, "There isn't '$tftpdir' directory on current server"; | ||||
|                     last; | ||||
|                 } | ||||
|                 my $tftp_ps = `ps aux 2>&1| grep tftp | grep xcat |grep -v grep`; | ||||
|                 if (!$tftp_ps) { | ||||
|                     push @$error_ref, "TFTP service based on xCAT is not running"; | ||||
|                     $flag = 'w'; | ||||
|                 } | ||||
|                 unless(probe_utils->is_tftp_ready("$serverip", $tftpdir)) { | ||||
|                     push @$error_ref, "TFTP service isn't ready on $serverip"; | ||||
|                     push @$error_ref, "TFTP service isn't ready on $serverip, stop tftp service and start it by restarting xcatd"; | ||||
|                     $flag = 'f'; | ||||
|                     last; | ||||
|                 } | ||||
|                 last if ($flag eq 'w'); | ||||
|                 $rst = 0; | ||||
|             } | ||||
|         } | ||||
| @@ -737,7 +746,7 @@ sub check_tftp_service { | ||||
|         $rst = 2; | ||||
|     } | ||||
|  | ||||
|     return $rst; | ||||
|     return ($rst, $flag); | ||||
| } | ||||
|  | ||||
| sub check_rsyslog_service { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user