1
0
angie-conv-image/image-entry.d/72-merge-tree.sh
2024-09-17 14:11:00 +03:00

44 lines
869 B
Bash
Executable File

#!/bin/sh
set -ef
. /image-entry.d/00-common.envsh
[ -d "${merged_root}" ] || install -d "${merged_root}"
remap_path_int() {
printf '%s' "$2/${1#*/}"
}
remap_path() {
case "$1" in
/etc/angie/* ) remap_path_int "${1#/etc/angie/}" "$2" ;;
/angie/* ) remap_path_int "${1#/angie/}" "$2" ;;
## misbehavior!
* )
log_always "remap_path() doesn't know how to handle this path: '$1'"
return 1
;;
esac
}
for n in j2cfg ${NGX_DIRS_MERGE} ; do
[ -n "$n" ] || continue
merged_dir="${merged_root}/$n"
while read -r old_path ; do
[ -n "${old_path}" ] || continue
new_path=$(remap_path "${old_path}" "${merged_dir}")
[ -n "${new_path}" ]
new_dir="${new_path%/*}"
[ -d "${new_dir}" ] || mkdir -p "${new_dir}"
ln_s "${old_path}" "${new_path}"
done <<-EOF
$(overlay-dir-list.sh "/etc/angie/$n.dist" "/etc/angie/$n" "/angie/$n")
EOF
done
exit 0