23 lines
574 B
Bash
23 lines
574 B
Bash
# shellcheck shell=bash
|
|
|
|
# shellcheck disable=SC2154
|
|
echo "Starting impermanence mount with source: $source, target: $target, path: $path."
|
|
|
|
source_current="$source"
|
|
target_current="$target"
|
|
|
|
IFS='/' read -ra path_parts <<< "$path"
|
|
unset "path_parts[-1]"
|
|
|
|
for part in "${path_parts[@]}"; do
|
|
source_current="$source_current/$part"
|
|
target_current="$target_current/$part"
|
|
|
|
if [[ ! -d "$source_current" ]]; then
|
|
break
|
|
fi
|
|
|
|
read -r mode owner group <<< "$(stat -c '%a %u %g' "$source_current")"
|
|
install -d -m "$mode" -o "$owner" -g "$group" "$target_current"
|
|
done
|