From: Peter Palfrader Date: Fri, 29 Sep 2017 09:33:27 +0000 (+0200) Subject: Be more defensive with mv and use --no-target-directory X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=74016955eecc54b87a7cd58927534a6b2871594d;p=mirror%2Fdsa-puppet.git Be more defensive with mv and use --no-target-directory --- diff --git a/modules/roles/files/static-mirroring/static-master-update-component b/modules/roles/files/static-mirroring/static-master-update-component index c115ae447..4ab5143e5 100755 --- a/modules/roles/files/static-mirroring/static-master-update-component +++ b/modules/roles/files/static-mirroring/static-master-update-component @@ -132,11 +132,11 @@ rsync --delete \ "$src/." "$tmpdir_new/." echo "$0: Done. Committing." -mv "$tgt" "$tmpdir_old/old" -if ! mv "$tmpdir_new" "$tgt"; then +mv --no-target-directory "$tgt" "$tmpdir_old/old" +if ! mv --no-target-directory "$tmpdir_new" "$tgt"; then echo >&2 "$0: WARNING: could not move $tmpdir_new to $tgt. Trying to recover" rm -rf "$tgt" - mv "$tmpdir_old/old" "$tgt" + mv --no-target-directory "$tmpdir_old/old" "$tgt" echo >&2 "$0: Rolled back to old tree, maybe even successfully." exit 1 fi