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

64 lines
1.2 KiB
Bash
Raw Normal View History

2024-07-11 13:37:35 +03:00
#!/bin/sh
2024-07-16 11:33:20 +03:00
set -f
2024-07-11 13:37:35 +03:00
. /image-entry.d/00-common.envsh
## Angie: unset core variable
unset ANGIE ANGIE_BPF_MAPS
2024-07-16 11:33:20 +03:00
[ "${NGX_STRICT_LOAD}" = 0 ] || set -e
2024-07-20 16:35:39 +03:00
cd "${merged_root}/"
2024-07-20 16:35:39 +03:00
expand_error_delim() {
IEP_DEBUG=0 log_always ' ----------------------------------- '
2024-07-20 16:35:39 +03:00
}
2024-07-26 01:18:59 +03:00
unset expand_error_seen
2024-07-16 11:33:20 +03:00
expand_error() {
2024-07-20 16:35:39 +03:00
[ "${expand_error_seen:-}" != 1 ] || return
2024-07-16 11:33:20 +03:00
expand_error_seen=1
2024-07-20 16:35:39 +03:00
expand_error_delim
log_always 'template expansion has failed'
2024-07-16 11:33:20 +03:00
if [ "${NGX_STRICT_LOAD}" = 1 ] ; then
2024-07-20 16:35:39 +03:00
t=15
2024-07-16 11:33:20 +03:00
log_always "injecting delay for $t seconds"
2024-07-20 16:35:39 +03:00
expand_error_delim
2024-07-16 11:33:20 +03:00
sleep $t
exit 1
fi
2024-07-20 16:35:39 +03:00
expand_error_delim
2024-07-16 11:33:20 +03:00
}
merge_dirs=
2024-07-20 16:35:39 +03:00
for n in ${NGX_DIRS_MERGE} ; do
[ -n "$n" ] || continue
[ -d "$n" ] || continue
2024-07-16 02:43:08 +03:00
2024-07-20 16:35:39 +03:00
merge_dirs="${merge_dirs} $n/"
2024-07-16 02:43:08 +03:00
done
2024-07-11 13:37:35 +03:00
2024-07-20 16:35:39 +03:00
set -a
J2CFG_PATH="${merged_root}/j2cfg"
J2CFG_SEARCH_PATH="${merged_root}"
2024-07-31 14:04:15 +03:00
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}"
2024-07-20 16:35:39 +03:00
expand_dir_j2cfg ${merge_dirs} || expand_error
2024-07-11 13:37:35 +03:00
exit 0