#!/usr/bin/env bash gitUrl="https://git.stormux.org/storm/gaming-image-files" gitPath="${gitUrl##*/}" pushd /tmp || exit git clone "${gitUrl}" pushd "${gitPath}" || exit git checkout testing git lfs pull # Files and directories to ignore when copying ignoreFiles=(".git" "./image" ".git*") # Build find command with ignore patterns findArgs=() for ignore in "${ignoreFiles[@]}"; do if [[ "$ignore" == .* && "$ignore" != ./* ]]; then findArgs+=(-name "$ignore" -prune -o) else findArgs+=(-path "$ignore" -prune -o) fi done # Copy all files as root (preserves permissions properly) find . "${findArgs[@]}" -type f -exec bash -c 'for i ; do cp -av --preserve=all --parents "${i}" /;done' _ "{}" \; # Fix ownership of home directory files chown -R stormux:users /home/stormux popd || exit rm -rf "${gitPath}" popd || exit exit 0