1
0
angie-conv-image/image-entry.d/73-expand-templates.sh

64 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2024-09-17 14:11:00 +03:00
#!/bin/sh
set -f
. /image-entry.d/00-common.envsh
## Angie: unset core variable
unset ANGIE ANGIE_BPF_MAPS
[ "${NGX_STRICT_LOAD}" = 0 ] || set -e
cd "${merged_root}/"
expand_error_delim() {
IEP_DEBUG=0 log_always ' ----------------------------------- '
}
unset expand_error_seen
expand_error() {
[ "${expand_error_seen:-}" != 1 ] || return
expand_error_seen=1
expand_error_delim
log_always 'template expansion has failed'
if [ "${NGX_STRICT_LOAD}" = 1 ] ; then
t=15
log_always "injecting delay for $t seconds"
expand_error_delim
sleep $t
exit 1
fi
expand_error_delim
}
merge_dirs=
for n in ${NGX_DIRS_MERGE} ; do
[ -n "$n" ] || continue
[ -d "$n" ] || continue
merge_dirs="${merge_dirs} $n/"
done
set -a
J2CFG_PATH="${merged_root}/j2cfg"
J2CFG_SEARCH_PATH="${merged_root}"
set +a
## expand j2cfg templates first
expand_dir_envsubst j2cfg/ || expand_error
expand_dir_j2cfg j2cfg/ || expand_error
## expand other templates
expand_dir_envsubst ${merge_dirs} || expand_error
unset j2cfg_dump
j2cfg_dump="${volume_root}/diag.j2cfg.yml"
j2cfg-dump > "${j2cfg_dump}" || expand_error
export J2CFG_CONFIG="${j2cfg_dump}"
expand_dir_j2cfg ${merge_dirs} || expand_error
exit 0