diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 5fda1acfd..6da8b3277 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -214,6 +214,11 @@ sub defer_syncfiles_to_postboot { unless defined($postscripts) && $postscripts =~ s/^[ \t]*syncfiles[ \t]*\n//m; $postbootscripts = "" unless defined $postbootscripts; + + # A node may already list syncfiles as a postbootscript of its own; do not add a second copy. + return ($postscripts, $postbootscripts) + if $postbootscripts =~ /^[ \t]*syncfiles[ \t]*$/m; + $postbootscripts = "# ubuntu-deferred-postbootscripts-start-here\nsyncfiles\n# ubuntu-deferred-postbootscripts-end-here\n" . $postbootscripts; diff --git a/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t b/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t index e0e935ffb..9962ea20c 100644 --- a/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t +++ b/xCAT-test/unit/postage_ubuntu_syncfiles_postboot.t @@ -83,6 +83,16 @@ foreach my $case (@untouched) { is($postboot, $DEFERRED, 'an undefined postbootscripts list becomes the deferral block'); } +# A node that already lists syncfiles as its own postbootscript keeps that entry, and does not +# gain a second one -- the install-time copy is still removed, since that is the one that cannot work. +{ + my ($post, $postboot) = + defer('ubuntu24.04', 'install', 'install', "syncfiles\nfoo\n", "syncfiles\nsetupntp\n"); + is($post, "foo\n", 'the postscripts entry is still removed'); + is($postboot, "syncfiles\nsetupntp\n", + "an admin's own syncfiles postbootscript is left as it was, not duplicated"); +} + # Rendering the same node twice must not stack a second copy. { my ($post, $postboot) =