diff options
-rwxr-xr-x | modules.d/slx-addons/hooks/s3-setup-addons.sh | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/modules.d/slx-addons/hooks/s3-setup-addons.sh b/modules.d/slx-addons/hooks/s3-setup-addons.sh index 495e3799..5068d2c2 100755 --- a/modules.d/slx-addons/hooks/s3-setup-addons.sh +++ b/modules.d/slx-addons/hooks/s3-setup-addons.sh @@ -57,15 +57,24 @@ setup_addon() { # purge addon-* files rm -f -- addon-* + # make directory struct, replicate owners/perms - should we keep-old-files? + echo "Replicating directory tree in $NEWROOT" + # Doing this once in advance instead of doing a mkdir for each file's parent directory + # every time in the loop below brought us from 3.6s down to 2.2s for VMware + find . -type d -print0 | tar --no-recursion --null -T - -c | tar -C "$NEWROOT" --keep-old-files -x # move all the files over - find . -not -type d 2>/dev/null | while read -r entry || [ -n "$entry" ]; do - entry="${entry#./}" - [ "$entry" != "${entry%/*}" ] && mkdir -p "${NEWROOT}/${entry%/*}" - mv -f -- "$entry" "${NEWROOT}/${entry}" - done + echo "Moving files over" + while read -r entry || [ -n "$entry" ]; do + # Doing the mv in parallel brought us from 2.2s to 380ms for VMware (~850 files), + # but I've no idea if there'd be an adverse effect if we had a lot more files + # to move and we'd spawn thousands of mv processes in parallel... + mv -f -- "$entry" "${NEWROOT}/${entry}" & + done < <( find . -not -type d ) # do it this way so we don't end up with a pipe-subshell + wait # and can properly wait for all the mv processes. # post merge: remove files marked as whiteouts # (e.g. they were removed during the addon installation) + echo "Applying whiteouts" for WHITEOUT in "$NEWROOT/opt/openslx/etc/"*.whiteout; do [ -e "$WHITEOUT" ] || continue while read -r line; do @@ -73,7 +82,7 @@ setup_addon() { done < "$WHITEOUT" done - cd - &>/dev/null + return 0 } active=() |