rework configuration handling
This commit is contained in:
parent
2af3420aec
commit
e6328b5cea
@ -153,6 +153,11 @@ COPY /angie/ /etc/angie/
|
|||||||
RUN find /etc/angie/ -name .gitkeep -delete ; \
|
RUN find /etc/angie/ -name .gitkeep -delete ; \
|
||||||
find /etc/angie/ ! -type l -exec chmod go-w {} +
|
find /etc/angie/ ! -type l -exec chmod go-w {} +
|
||||||
|
|
||||||
|
## preseed builtin modules list
|
||||||
|
RUN x='angie-builtin-modules.sh' ; \
|
||||||
|
"$x" ; \
|
||||||
|
chmod a-x $(which "$x")
|
||||||
|
|
||||||
## misc tools
|
## misc tools
|
||||||
RUN apt-install.sh \
|
RUN apt-install.sh \
|
||||||
brotli \
|
brotli \
|
||||||
@ -195,4 +200,4 @@ ENV DUMB_INIT_SETSID=0 \
|
|||||||
STOPSIGNAL SIGQUIT
|
STOPSIGNAL SIGQUIT
|
||||||
|
|
||||||
ENTRYPOINT [ "image-entry.sh" ]
|
ENTRYPOINT [ "image-entry.sh" ]
|
||||||
CMD [ "angie", "-g", "daemon off;" ]
|
CMD [ "angie" ]
|
||||||
|
3
angie/.none.conf
Normal file
3
angie/.none.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
daemon off;
|
||||||
|
master_process off;
|
||||||
|
events {}
|
@ -1,8 +1,9 @@
|
|||||||
|
daemon off;
|
||||||
pid run/angie.pid;
|
pid run/angie.pid;
|
||||||
lock_file lock.d/angie.lock;
|
lock_file lock.d/angie.lock;
|
||||||
|
|
||||||
## almost useless
|
## almost useless
|
||||||
include mod.d/core-*.conf;
|
include mod.d/core-*.load;
|
||||||
|
|
||||||
# mod-http.conf.in
|
# mod-http.conf.in
|
||||||
# mod-mail.conf.in
|
# mod-mail.conf.in
|
||||||
@ -11,10 +12,10 @@ include run/mod-*.conf;
|
|||||||
|
|
||||||
events {
|
events {
|
||||||
include conf.d/core_ev-*.conf;
|
include conf.d/core_ev-*.conf;
|
||||||
include snip.d/core_ev-*.conf;
|
include snip.d/core_ev-*.load;
|
||||||
}
|
}
|
||||||
include conf.d/core-*.conf;
|
include conf.d/core-*.conf;
|
||||||
include snip.d/core-*.conf;
|
include snip.d/core-*.load;
|
||||||
|
|
||||||
# ctx-http.conf.in
|
# ctx-http.conf.in
|
||||||
# ctx-mail.conf.in
|
# ctx-mail.conf.in
|
||||||
|
7
angie/conf.dist/http-buffers.conf
Normal file
7
angie/conf.dist/http-buffers.conf
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
subrequest_output_buffer_size 16k;
|
||||||
|
client_body_buffer_size 16k;
|
||||||
|
client_header_buffer_size 4k;
|
||||||
|
large_client_header_buffers 8 16k;
|
||||||
|
|
||||||
|
## lowering from 16k to 4k to improve time-to-first-byte
|
||||||
|
ssl_buffer_size 4k;
|
@ -1,5 +1,5 @@
|
|||||||
http {
|
http {
|
||||||
include conf.d/http-*.conf;
|
include conf.d/http-*.conf;
|
||||||
include snip.d/http-*.conf;
|
include snip.d/http-*.load;
|
||||||
include site.d/http-*.conf;
|
include site.d/http-*.conf;
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
mail {
|
mail {
|
||||||
include conf.d/mail-*.conf;
|
include conf.d/mail-*.conf;
|
||||||
include snip.d/mail-*.conf;
|
include snip.d/mail-*.load;
|
||||||
include site.d/mail-*.conf;
|
include site.d/mail-*.conf;
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
stream {
|
stream {
|
||||||
include conf.d/stream-*.conf;
|
include conf.d/stream-*.conf;
|
||||||
include snip.d/stream-*.conf;
|
include snip.d/stream-*.load;
|
||||||
include site.d/stream-*.conf;
|
include site.d/stream-*.conf;
|
||||||
}
|
}
|
@ -1 +1 @@
|
|||||||
include mod.d/http-*.conf;
|
include mod.d/http-*.load;
|
@ -1 +1 @@
|
|||||||
include mod.d/mail-*.conf;
|
include mod.d/mail-*.load;
|
@ -1 +1 @@
|
|||||||
include mod.d/stream-*.conf;
|
include mod.d/stream-*.load;
|
@ -1 +0,0 @@
|
|||||||
load_module modules.d/ngx_http_brotli_filter_module.so;
|
|
@ -1,2 +1 @@
|
|||||||
load_module modules.d/ngx_http_brotli_filter_module.so;
|
load_module modules.d/ngx_http_brotli_filter_module.so;
|
||||||
load_module modules.d/ngx_http_brotli_static_module.so;
|
|
@ -1 +0,0 @@
|
|||||||
load_module modules.d/ngx_http_zstd_filter_module.so;
|
|
@ -1,2 +1 @@
|
|||||||
load_module modules.d/ngx_http_zstd_filter_module.so;
|
load_module modules.d/ngx_http_zstd_filter_module.so;
|
||||||
load_module modules.d/ngx_http_zstd_static_module.so;
|
|
2
angie/snip.dist/http-brotli-static.conf
Normal file
2
angie/snip.dist/http-brotli-static.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
## no extra configuration is present at this time
|
||||||
|
## ref: https://github.com/google/ngx_brotli/
|
24
angie/snip.dist/http-brotli.conf
Normal file
24
angie/snip.dist/http-brotli.conf
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
## default is 6
|
||||||
|
brotli_comp_level 5;
|
||||||
|
## default is 512k
|
||||||
|
brotli_window 64k;
|
||||||
|
|
||||||
|
brotli_min_length 1024;
|
||||||
|
brotli_buffers 32 16k;
|
||||||
|
|
||||||
|
brotli_types
|
||||||
|
application/atom+xml
|
||||||
|
application/javascript
|
||||||
|
application/json
|
||||||
|
application/vnd.api+json
|
||||||
|
application/rss+xml
|
||||||
|
application/x-javascript
|
||||||
|
application/xhtml+xml
|
||||||
|
application/xml
|
||||||
|
image/svg+xml
|
||||||
|
image/x-icon
|
||||||
|
text/css
|
||||||
|
text/javascript
|
||||||
|
text/plain
|
||||||
|
text/xml
|
||||||
|
;
|
1
angie/snip.dist/http-gunzip.conf
Normal file
1
angie/snip.dist/http-gunzip.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
gunzip_buffers 16 16k;
|
2
angie/snip.dist/http-gzip-static.conf
Normal file
2
angie/snip.dist/http-gzip-static.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
## no extra configuration is present at this time
|
||||||
|
## ref: https://angie.software/en/configuration/modules/http_gzip_static/
|
25
angie/snip.dist/http-gzip.conf
Normal file
25
angie/snip.dist/http-gzip.conf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
## default is 1
|
||||||
|
gzip_comp_level 2;
|
||||||
|
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_buffers 32 16k;
|
||||||
|
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
|
||||||
|
gzip_types
|
||||||
|
application/atom+xml
|
||||||
|
application/javascript
|
||||||
|
application/json
|
||||||
|
application/vnd.api+json
|
||||||
|
application/rss+xml
|
||||||
|
application/x-javascript
|
||||||
|
application/xhtml+xml
|
||||||
|
application/xml
|
||||||
|
image/svg+xml
|
||||||
|
image/x-icon
|
||||||
|
text/css
|
||||||
|
text/javascript
|
||||||
|
text/plain
|
||||||
|
text/xml
|
||||||
|
;
|
2
angie/snip.dist/http-zstd-static.conf
Normal file
2
angie/snip.dist/http-zstd-static.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
## no extra configuration is present at this time
|
||||||
|
## ref: https://github.com/tokers/zstd-nginx-module/
|
22
angie/snip.dist/http-zstd.conf
Normal file
22
angie/snip.dist/http-zstd.conf
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
## default is 1
|
||||||
|
zstd_comp_level 2;
|
||||||
|
|
||||||
|
zstd_min_length 1024;
|
||||||
|
zstd_buffers 32 16k;
|
||||||
|
|
||||||
|
zstd_types
|
||||||
|
application/atom+xml
|
||||||
|
application/javascript
|
||||||
|
application/json
|
||||||
|
application/vnd.api+json
|
||||||
|
application/rss+xml
|
||||||
|
application/x-javascript
|
||||||
|
application/xhtml+xml
|
||||||
|
application/xml
|
||||||
|
image/svg+xml
|
||||||
|
image/x-icon
|
||||||
|
text/css
|
||||||
|
text/javascript
|
||||||
|
text/plain
|
||||||
|
text/xml
|
||||||
|
;
|
@ -1,5 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
volume_root='/run/angie'
|
||||||
|
tmp_dir="${volume_root}/tmp"
|
||||||
|
merged_root="${volume_root}/merged"
|
||||||
|
target_root="${volume_root}"
|
||||||
|
|
||||||
have_envvar() {
|
have_envvar() {
|
||||||
[ -n "$1" ] || return 1
|
[ -n "$1" ] || return 1
|
||||||
grep -Ezq "^$1=" /proc/self/environ || return
|
grep -Ezq "^$1=" /proc/self/environ || return
|
||||||
@ -45,18 +50,28 @@ IEP_VERBOSE=$(gobool_to_int "${IEP_VERBOSE:-${IEP_TRACE}}" "${IEP_TRACE}")
|
|||||||
export IEP_VERBOSE
|
export IEP_VERBOSE
|
||||||
if [ "${IEP_VERBOSE}" = 1 ] ; then
|
if [ "${IEP_VERBOSE}" = 1 ] ; then
|
||||||
log() { log_always "$@" ; }
|
log() { log_always "$@" ; }
|
||||||
log_file() { sed -E '/^./s,^, ,' < "$1" >&2 ; }
|
|
||||||
else
|
else
|
||||||
log() { : ;}
|
log() { : ;}
|
||||||
log_file() { :; }
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log_file() { sed -E '/^./s,^, ,' < "$1" >&2 ; }
|
||||||
|
|
||||||
if [ "${IEP_VERBOSE}" = 0 ] ; then
|
if [ "${IEP_VERBOSE}" = 0 ] ; then
|
||||||
ln_s() { ln -s "$@" || return; }
|
ln_s() { ln -s "$@" || return; }
|
||||||
|
cp_a() { cp -a "$@" || return; }
|
||||||
else
|
else
|
||||||
ln_s() { ln -sv "$@" || return; }
|
ln_s() { ln -sv "$@" || return; }
|
||||||
|
cp_a() { cp -av "$@" || return; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ln_cp() {
|
||||||
|
if [ -h "$1" ] ; then
|
||||||
|
ln_s "$(readlink -e "$1")" "$2"
|
||||||
|
else
|
||||||
|
cp_a "$1" "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
have_cmd() { command -v "$1" >/dev/null 2>&1 || return ; }
|
have_cmd() { command -v "$1" >/dev/null 2>&1 || return ; }
|
||||||
|
|
||||||
strip_suffix() { printf '%s' "${1%"$2"}" | tr -s '/' ; }
|
strip_suffix() { printf '%s' "${1%"$2"}" | tr -s '/' ; }
|
||||||
@ -64,7 +79,7 @@ strip_suffix() { printf '%s' "${1%"$2"}" | tr -s '/' ; }
|
|||||||
untemplate_path() {
|
untemplate_path() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
## inplace
|
## inplace
|
||||||
/run/angie/* | /etc/angie/run/* )
|
"${volume_root}"/* | /etc/angie/run/* )
|
||||||
strip_suffix "$1" "$2"
|
strip_suffix "$1" "$2"
|
||||||
;;
|
;;
|
||||||
/etc/angie/conf.d/* | /etc/angie/mod.d/* | /etc/angie/modules.d/* | /etc/angie/njs.d/* | /etc/angie/site.d/* | /etc/angie/snip.d/* )
|
/etc/angie/conf.d/* | /etc/angie/mod.d/* | /etc/angie/modules.d/* | /etc/angie/njs.d/* | /etc/angie/site.d/* | /etc/angie/snip.d/* )
|
||||||
@ -75,7 +90,7 @@ untemplate_path() {
|
|||||||
;;
|
;;
|
||||||
## set appropriate location
|
## set appropriate location
|
||||||
/etc/angie/* )
|
/etc/angie/* )
|
||||||
strip_suffix "/run/angie${1#/etc/angie}" "$2"
|
strip_suffix "${volume_root}${1#/etc/angie}" "$2"
|
||||||
;;
|
;;
|
||||||
/tmp/* )
|
/tmp/* )
|
||||||
log_always "untemplate_path() shouldn't work with /tmp/: $1"
|
log_always "untemplate_path() shouldn't work with /tmp/: $1"
|
||||||
@ -84,7 +99,7 @@ untemplate_path() {
|
|||||||
## last resort - STRONGLY AVOID
|
## last resort - STRONGLY AVOID
|
||||||
/* )
|
/* )
|
||||||
log_always "untemplate_path() does uncommon/last-resort mapping for: $1"
|
log_always "untemplate_path() does uncommon/last-resort mapping for: $1"
|
||||||
strip_suffix "/run/angie/tmp$1" "$2"
|
strip_suffix "${tmp_dir}$1" "$2"
|
||||||
;;
|
;;
|
||||||
## misbehavior!
|
## misbehavior!
|
||||||
* )
|
* )
|
||||||
@ -111,6 +126,11 @@ untemplate_file_envsubst() {
|
|||||||
__dest="$2"
|
__dest="$2"
|
||||||
[ -n "${__dest}" ] || __dest=$(untemplate_path "$1" "${NGX_ENVSUBST_SUFFIX}") || return
|
[ -n "${__dest}" ] || __dest=$(untemplate_path "$1" "${NGX_ENVSUBST_SUFFIX}") || return
|
||||||
|
|
||||||
|
if [ -e "${__dest}" ] ; then
|
||||||
|
log "untemplate_file_envsubst: destination file already exists"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
[ -d "${__dest%/*}" ] || install_userdir "${__dest%/*}" || return
|
[ -d "${__dest%/*}" ] || install_userdir "${__dest%/*}" || return
|
||||||
|
|
||||||
log "Running envsubst: $1 -> ${__dest}"
|
log "Running envsubst: $1 -> ${__dest}"
|
||||||
@ -129,6 +149,11 @@ untemplate_file_jinja() {
|
|||||||
__dest="$2"
|
__dest="$2"
|
||||||
[ -n "${__dest}" ] || __dest=$(untemplate_path "$1" "${NGX_JINJA_SUFFIX}") || return
|
[ -n "${__dest}" ] || __dest=$(untemplate_path "$1" "${NGX_JINJA_SUFFIX}") || return
|
||||||
|
|
||||||
|
if [ -e "${__dest}" ] ; then
|
||||||
|
log "untemplate_file_jinja: destination file already exists"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
[ -d "${__dest%/*}" ] || install_userdir "${__dest%/*}" || return
|
[ -d "${__dest%/*}" ] || install_userdir "${__dest%/*}" || return
|
||||||
|
|
||||||
log "Running jinja.py: $1 -> ${__dest}"
|
log "Running jinja.py: $1 -> ${__dest}"
|
||||||
@ -152,10 +177,11 @@ untemplate_dir_envsubst() {
|
|||||||
export ENVSUBST_ARGS
|
export ENVSUBST_ARGS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while read -r _orig_file ; do
|
while read -r __orig_file ; do
|
||||||
[ -n "${_orig_file}" ] || continue
|
[ -n "${__orig_file}" ] || continue
|
||||||
untemplate_file_envsubst "${_orig_file}"
|
untemplate_file_envsubst "${__orig_file}"
|
||||||
done < "${__template_list}"
|
done < "${__template_list}"
|
||||||
|
unset __orig_file
|
||||||
|
|
||||||
if [ -z "${__have_args}" ] ; then
|
if [ -z "${__have_args}" ] ; then
|
||||||
rm -f "${ENVSUBST_ARGS}" ; unset ENVSUBST_ARGS
|
rm -f "${ENVSUBST_ARGS}" ; unset ENVSUBST_ARGS
|
||||||
@ -173,10 +199,11 @@ untemplate_dir_jinja() {
|
|||||||
find "$@" -follow -type f -name "*${NGX_JINJA_SUFFIX}" \
|
find "$@" -follow -type f -name "*${NGX_JINJA_SUFFIX}" \
|
||||||
| sort -uV > "${__template_list}"
|
| sort -uV > "${__template_list}"
|
||||||
|
|
||||||
while read -r _orig_file ; do
|
while read -r __orig_file ; do
|
||||||
[ -n "${_orig_file}" ] || continue
|
[ -n "${__orig_file}" ] || continue
|
||||||
untemplate_file_jinja "${_orig_file}"
|
untemplate_file_jinja "${__orig_file}"
|
||||||
done < "${__template_list}"
|
done < "${__template_list}"
|
||||||
|
unset __orig_file
|
||||||
|
|
||||||
rm -f "${__template_list}" ; unset __template_list
|
rm -f "${__template_list}" ; unset __template_list
|
||||||
}
|
}
|
||||||
@ -227,12 +254,11 @@ remap_path() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
merged_root='/run/angie/merged'
|
|
||||||
combine_remap_path() {
|
combine_remap_path() {
|
||||||
[ -n "$1" ] || return
|
[ -n "$1" ] || return
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"${merged_root}"/* ) echo "${2:-/run/angie}${1#"${merged_root}"}" ;;
|
"${merged_root}"/* ) echo "${2:-${target_root}}${1#"${merged_root}"}" ;;
|
||||||
## misbehavior!
|
## misbehavior!
|
||||||
* )
|
* )
|
||||||
log_always "combine_remap_path() doesn't know how to handle this path: $1"
|
log_always "combine_remap_path() doesn't know how to handle this path: $1"
|
||||||
@ -240,3 +266,21 @@ combine_remap_path() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_builtin_module() {
|
||||||
|
[ -n "${1:-}" ] || return 1
|
||||||
|
[ -n "${2:-}" ] || return 1
|
||||||
|
|
||||||
|
[ -f "/etc/angie/builtin.$1" ] || return 1
|
||||||
|
[ -s "/etc/angie/builtin.$1" ] || return 1
|
||||||
|
|
||||||
|
grep -Fxq -e "$2" "/etc/angie/builtin.$1" || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
sort_dedup_list() {
|
||||||
|
[ -n "$1" ] || return 0
|
||||||
|
|
||||||
|
printf '%s' "$1" \
|
||||||
|
| tr -s '[:space:]' '\n' | sort -uV | paste -sd ' ' \
|
||||||
|
| sed -zE 's/^\s+//;s/\s+$//'
|
||||||
|
}
|
||||||
|
38
image-entry.d/10-core-modules.envsh
Executable file
38
image-entry.d/10-core-modules.envsh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
unset core_modules core_snippets
|
||||||
|
core_modules=
|
||||||
|
core_snippets="${NGX_CORE_SNIPPETS:-}"
|
||||||
|
|
||||||
|
## filter out builtin core modules
|
||||||
|
unset i
|
||||||
|
for i in ${NGX_CORE_MODULES:-} ; do
|
||||||
|
[ -n "$i" ] || continue
|
||||||
|
|
||||||
|
if is_builtin_module core "$i" ; then
|
||||||
|
log "$i is builtin module, moving to snippets"
|
||||||
|
core_snippets="${core_snippets}${core_snippets:+ }$i"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
## naive deduplication
|
||||||
|
case " ${core_modules} " in
|
||||||
|
*" $i "* )
|
||||||
|
log "$i is already specified"
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
core_modules="${core_modules}${core_modules:+ }$i"
|
||||||
|
done
|
||||||
|
unset i
|
||||||
|
|
||||||
|
## sort and remove duplicates
|
||||||
|
core_snippets=$(sort_dedup_list "${core_snippets}")
|
||||||
|
|
||||||
|
set -a
|
||||||
|
NGX_CORE_MODULES="${core_modules}"
|
||||||
|
NGX_CORE_SNIPPETS="${core_snippets}"
|
||||||
|
set +a
|
||||||
|
|
||||||
|
unset core_modules core_snippets
|
39
image-entry.d/21-http-modules.envsh
Executable file
39
image-entry.d/21-http-modules.envsh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "${NGX_HTTP}" = 1 ] ; then
|
||||||
|
unset http_modules http_snippets
|
||||||
|
http_modules=
|
||||||
|
http_snippets="${NGX_HTTP_SNIPPETS:-}"
|
||||||
|
|
||||||
|
## filter out builtin http modules
|
||||||
|
unset i
|
||||||
|
for i in ${NGX_HTTP_MODULES:-} ; do
|
||||||
|
[ -n "$i" ] || continue
|
||||||
|
|
||||||
|
if is_builtin_module http "$i" ; then
|
||||||
|
log "$i is builtin module, moving to snippets"
|
||||||
|
http_snippets="${http_snippets}${http_snippets:+ }$i"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
## naive deduplication
|
||||||
|
case " ${http_modules} " in
|
||||||
|
*" $i "* )
|
||||||
|
log "$i is already specified"
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
http_modules="${http_modules}${http_modules:+ }$i"
|
||||||
|
done
|
||||||
|
unset i
|
||||||
|
|
||||||
|
http_snippets=$(sort_dedup_list "${http_snippets}")
|
||||||
|
|
||||||
|
set -a
|
||||||
|
NGX_HTTP_MODULES="${http_modules}"
|
||||||
|
NGX_HTTP_SNIPPETS="${http_snippets}"
|
||||||
|
set +a
|
||||||
|
|
||||||
|
unset http_modules http_snippets
|
||||||
|
fi
|
39
image-entry.d/31-mail-modules.envsh
Executable file
39
image-entry.d/31-mail-modules.envsh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "${NGX_MAIL}" = 1 ] ; then
|
||||||
|
unset mail_modules mail_snippets
|
||||||
|
mail_modules=
|
||||||
|
mail_snippets="${NGX_MAIL_SNIPPETS:-}"
|
||||||
|
|
||||||
|
## filter out builtin mail modules
|
||||||
|
unset i
|
||||||
|
for i in ${NGX_MAIL_MODULES:-} ; do
|
||||||
|
[ -n "$i" ] || continue
|
||||||
|
|
||||||
|
if is_builtin_module mail "$i" ; then
|
||||||
|
log "$i is builtin module, moving to snippets"
|
||||||
|
mail_snippets="${mail_snippets}${mail_snippets:+ }$i"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
## naive deduplication
|
||||||
|
case " ${mail_modules} " in
|
||||||
|
*" $i "* )
|
||||||
|
log "$i is already specified"
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
mail_modules="${mail_modules}${mail_modules:+ }$i"
|
||||||
|
done
|
||||||
|
unset i
|
||||||
|
|
||||||
|
mail_snippets=$(sort_dedup_list "${mail_snippets}")
|
||||||
|
|
||||||
|
set -a
|
||||||
|
NGX_MAIL_MODULES="${mail_modules}"
|
||||||
|
NGX_MAIL_SNIPPETS="${mail_snippets}"
|
||||||
|
set +a
|
||||||
|
|
||||||
|
unset mail_modules mail_snippets
|
||||||
|
fi
|
39
image-entry.d/41-stream-modules.envsh
Executable file
39
image-entry.d/41-stream-modules.envsh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "${NGX_STREAM}" = 1 ] ; then
|
||||||
|
unset stream_modules stream_snippets
|
||||||
|
stream_modules=
|
||||||
|
stream_snippets="${NGX_STREAM_SNIPPETS:-}"
|
||||||
|
|
||||||
|
## filter out builtin stream modules
|
||||||
|
unset i
|
||||||
|
for i in ${NGX_STREAM_MODULES:-} ; do
|
||||||
|
[ -n "$i" ] || continue
|
||||||
|
|
||||||
|
if is_builtin_module stream "$i" ; then
|
||||||
|
log "$i is builtin module, moving to snippets"
|
||||||
|
stream_snippets="${stream_snippets}${stream_snippets:+ }$i"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
## naive deduplication
|
||||||
|
case " ${stream_modules} " in
|
||||||
|
*" $i "* )
|
||||||
|
log "$i is already specified"
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
stream_modules="${stream_modules}${stream_modules:+ }$i"
|
||||||
|
done
|
||||||
|
unset i
|
||||||
|
|
||||||
|
stream_snippets=$(sort_dedup_list "${stream_snippets}")
|
||||||
|
|
||||||
|
set -a
|
||||||
|
NGX_STREAM_MODULES="${stream_modules}"
|
||||||
|
NGX_STREAM_SNIPPETS="${stream_snippets}"
|
||||||
|
set +a
|
||||||
|
|
||||||
|
unset stream_modules stream_snippets
|
||||||
|
fi
|
@ -3,9 +3,9 @@ set -f
|
|||||||
|
|
||||||
. /image-entry.d/00-common.envsh
|
. /image-entry.d/00-common.envsh
|
||||||
|
|
||||||
find /run/angie/ -mindepth 1 -exec rm -rf {} +
|
find "${volume_root}/" -mindepth 1 -exec rm -rf {} +
|
||||||
|
|
||||||
[ -d /run/angie/tmp ] || install -d -m 03777 /run/angie/tmp
|
[ -d "${tmp_dir}" ] || install -d -m 03777 "${tmp_dir}"
|
||||||
[ -d /run/angie/lock ] || install_userdir /run/angie/lock
|
[ -d "${volume_root}/lock" ] || install_userdir "${volume_root}/lock"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -4,7 +4,7 @@ set -f
|
|||||||
. /image-entry.d/00-common.envsh
|
. /image-entry.d/00-common.envsh
|
||||||
|
|
||||||
s=/etc/angie
|
s=/etc/angie
|
||||||
d=/run/angie
|
d=${target_root}
|
||||||
|
|
||||||
comps=''
|
comps=''
|
||||||
[ "${NGX_HTTP}" = 0 ] || comps="${comps} http"
|
[ "${NGX_HTTP}" = 0 ] || comps="${comps} http"
|
||||||
|
@ -3,6 +3,22 @@ set -f
|
|||||||
|
|
||||||
. /image-entry.d/00-common.envsh
|
. /image-entry.d/00-common.envsh
|
||||||
|
|
||||||
|
## sanity check
|
||||||
|
t=$(mktemp) || exit 1
|
||||||
|
|
||||||
|
for n in mod snip ; do
|
||||||
|
[ -d "${merged_root}/$n" ] || continue
|
||||||
|
find "${merged_root}/$n/" ! -type d
|
||||||
|
done \
|
||||||
|
| grep -E "^${merged_root}/(mod|snip)/.+\.load\$" \
|
||||||
|
| sort -V > "$t"
|
||||||
|
|
||||||
|
if [ -s "$t" ] ; then
|
||||||
|
log_always 'these files will be EXPLICITLY skipped:'
|
||||||
|
log_file "$t"
|
||||||
|
fi
|
||||||
|
rm -f "$t" ; unset t
|
||||||
|
|
||||||
[ "${NGX_STRICT_LOAD}" = 0 ] || set -e
|
[ "${NGX_STRICT_LOAD}" = 0 ] || set -e
|
||||||
|
|
||||||
load_error() {
|
load_error() {
|
||||||
@ -16,15 +32,26 @@ load_error() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
smart_ln() {
|
dirs='cache lib log'
|
||||||
if [ -h "$1" ] ; then
|
for n in ${dirs} ; do
|
||||||
ln_s "$(readlink -e "$1")" "$2"
|
s="/angie/$n"
|
||||||
else
|
d="${target_root}/$n"
|
||||||
cp "$1" "$2"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
dirs='conf modules njs site'
|
if [ -d "$s" ] ; then
|
||||||
|
ln_s "$s" "$d"
|
||||||
|
else
|
||||||
|
[ -d "$d" ] || install_userdir "$d"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
## provide same symlinks as upstream (both Angie and nginx) docker images do
|
||||||
|
d="${target_root}/log"
|
||||||
|
[ -e "$d/access.log" ] || ln_s /dev/stdout "$d/access.log"
|
||||||
|
[ -e "$d/error.log" ] || ln_s /dev/stderr "$d/error.log"
|
||||||
|
|
||||||
|
## NB: if any error occurs above then configuration is merely empty and/or broken
|
||||||
|
|
||||||
|
dirs='conf mod modules njs site snip'
|
||||||
[ "${NGX_PROCESS_STATIC}" = 0 ] || dirs="${dirs} static"
|
[ "${NGX_PROCESS_STATIC}" = 0 ] || dirs="${dirs} static"
|
||||||
while read -r old_path ; do
|
while read -r old_path ; do
|
||||||
[ -n "${old_path}" ] || continue
|
[ -n "${old_path}" ] || continue
|
||||||
@ -35,68 +62,91 @@ while read -r old_path ; do
|
|||||||
new_dir="${new_path%/*}"
|
new_dir="${new_path%/*}"
|
||||||
[ -d "${new_dir}" ] || mkdir -p "${new_dir}"
|
[ -d "${new_dir}" ] || mkdir -p "${new_dir}"
|
||||||
|
|
||||||
smart_ln "${old_path}" "${new_path}"
|
ln_cp "${old_path}" "${new_path}"
|
||||||
done <<-EOF
|
done <<-EOF
|
||||||
$(
|
$(
|
||||||
|
set +e
|
||||||
for n in ${dirs} ; do
|
for n in ${dirs} ; do
|
||||||
[ -d "${merged_root}/$n" ] || continue
|
[ -d "${merged_root}/$n" ] || continue
|
||||||
find "${merged_root}/$n/" ! -type d
|
find "${merged_root}/$n/" ! -type d
|
||||||
done | sort -V
|
done \
|
||||||
|
| grep -Ev \
|
||||||
|
-e "^${merged_root}/(mod|snip)/.+\.load\$" \
|
||||||
|
-e "^${merged_root}/mod/[^/]+\.preseed\$" \
|
||||||
|
| sort -V
|
||||||
|
set -e
|
||||||
)
|
)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ "${NGX_PROCESS_STATIC}" = 0 ] ; then
|
if [ "${NGX_PROCESS_STATIC}" = 0 ] ; then
|
||||||
for d in /angie/static /etc/angie/static /etc/angie/static.dist ; do
|
for d in /angie/static /etc/angie/static /etc/angie/static.dist ; do
|
||||||
[ -d "$d" ] || continue
|
[ -d "$d" ] || continue
|
||||||
ln_s "$d" /run/angie/static
|
ln_s "$d" "${target_root}/static"
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dirs='cache lib log'
|
|
||||||
for n in ${dirs} ; do
|
|
||||||
s="/angie/$n"
|
|
||||||
d="/run/angie/$n"
|
|
||||||
|
|
||||||
if [ -d "$s" ] ; then
|
|
||||||
ln_s "$s" "$d"
|
|
||||||
else
|
|
||||||
[ -d "$d" ] || install_userdir "$d"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
## provide same symlinks as upstream (both Angie and nginx) docker images do
|
|
||||||
d=/run/angie/log
|
|
||||||
[ -e "$d/access.log" ] || ln_s /dev/stdout "$d/access.log"
|
|
||||||
[ -e "$d/error.log" ] || ln_s /dev/stderr "$d/error.log"
|
|
||||||
|
|
||||||
## Angie modules are loaded in [strict] order!
|
## Angie modules are loaded in [strict] order!
|
||||||
combine_modules() {
|
combine_modules() {
|
||||||
[ -n "$1" ] || return 1
|
[ -n "$1" ] || return 1
|
||||||
n="$1" ; shift
|
n="$1" ; shift
|
||||||
|
|
||||||
|
[ $# -ne 0 ] || return 0
|
||||||
|
|
||||||
|
old_dir="${merged_root}/mod"
|
||||||
|
new_dir="${target_root}/mod"
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
for m ; do
|
for m ; do
|
||||||
[ -n "$m" ] || continue
|
[ -n "$m" ] || continue
|
||||||
|
|
||||||
old_name="mod/$n-$m.conf"
|
old_name="$n-$m.conf"
|
||||||
|
old_path="${old_dir}/${old_name}"
|
||||||
old_path="${merged_root}/${old_name}"
|
|
||||||
if ! [ -f "${old_path}" ] ; then
|
if ! [ -f "${old_path}" ] ; then
|
||||||
log_always "file ${old_name} is not found"
|
log_always "file ${old_name} is not found in ${old_dir}/"
|
||||||
load_error
|
load_error
|
||||||
log "file ${old_name} is skipped"
|
log "file ${old_name} is skipped"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new_path=$(printf "/run/angie/mod/$n-%02d-%s.conf" "$i" "$m")
|
new_name=$(printf "%s-%02d-%s.load" "$n" "$i" "$m")
|
||||||
new_dir="${new_path%/*}"
|
new_path="${new_dir}/${new_name}"
|
||||||
[ -d "${new_dir}" ] || mkdir -p "${new_dir}"
|
|
||||||
|
|
||||||
smart_ln "${old_path}" "${new_path}"
|
ln_cp "${old_path}" "${new_path}"
|
||||||
|
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
done
|
done ; unset m
|
||||||
|
}
|
||||||
|
|
||||||
|
combine_snippets() {
|
||||||
|
[ -n "$1" ] || return 1
|
||||||
|
n="$1" ; shift
|
||||||
|
|
||||||
|
[ $# -ne 0 ] || return 0
|
||||||
|
|
||||||
|
old_dir="${merged_root}/snip"
|
||||||
|
new_dir="${target_root}/snip"
|
||||||
|
|
||||||
|
for s ; do
|
||||||
|
[ -n "$s" ] || continue
|
||||||
|
|
||||||
|
new_path="${new_dir}/$n-$s.load"
|
||||||
|
if [ -e "${new_path}" ] ; then
|
||||||
|
log "${new_path} already exists, skipping"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
old_name="$n-$s.conf"
|
||||||
|
old_path="${old_dir}/${old_name}"
|
||||||
|
if ! [ -f "${old_path}" ] ; then
|
||||||
|
log_always "file ${old_name} is not found in ${old_dir}/"
|
||||||
|
load_error
|
||||||
|
log "file ${old_name} is skipped"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln_cp "${old_path}" "${new_path}"
|
||||||
|
done ; unset s
|
||||||
}
|
}
|
||||||
|
|
||||||
combine_modules core ${NGX_CORE_MODULES:-}
|
combine_modules core ${NGX_CORE_MODULES:-}
|
||||||
@ -104,82 +154,15 @@ combine_modules http ${NGX_HTTP_MODULES:-}
|
|||||||
combine_modules mail ${NGX_MAIL_MODULES:-}
|
combine_modules mail ${NGX_MAIL_MODULES:-}
|
||||||
combine_modules stream ${NGX_STREAM_MODULES:-}
|
combine_modules stream ${NGX_STREAM_MODULES:-}
|
||||||
|
|
||||||
combine_snippets() {
|
|
||||||
[ -n "$1" ] || return 1
|
|
||||||
n="$1" ; shift
|
|
||||||
|
|
||||||
for s ; do
|
|
||||||
[ -n "$s" ] || continue
|
|
||||||
|
|
||||||
old_name="snip/$n-$s.conf"
|
|
||||||
|
|
||||||
old_path="${merged_root}/${old_name}"
|
|
||||||
if ! [ -f "${old_path}" ] ; then
|
|
||||||
log_always "file ${old_name} is not found"
|
|
||||||
load_error
|
|
||||||
log "file ${old_name} is skipped"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
new_path="/run/angie/${old_name}"
|
|
||||||
new_dir="${new_path%/*}"
|
|
||||||
[ -d "${new_dir}" ] || mkdir -p "${new_dir}"
|
|
||||||
|
|
||||||
smart_ln "${old_path}" "${new_path}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
combine_snippets core ${NGX_CORE_SNIPPETS:-}
|
combine_snippets core ${NGX_CORE_SNIPPETS:-}
|
||||||
combine_snippets core_ev ${NGX_CORE_EVENTS_SNIPPETS:-}
|
combine_snippets core_ev ${NGX_CORE_EVENTS_SNIPPETS:-}
|
||||||
combine_snippets http ${NGX_HTTP_SNIPPETS:-}
|
combine_snippets http ${NGX_HTTP_SNIPPETS:-}
|
||||||
combine_snippets mail ${NGX_MAIL_SNIPPETS:-}
|
combine_snippets mail ${NGX_MAIL_SNIPPETS:-}
|
||||||
combine_snippets stream ${NGX_STREAM_SNIPPETS:-}
|
combine_snippets stream ${NGX_STREAM_SNIPPETS:-}
|
||||||
|
|
||||||
combine_module_snippets() {
|
combine_snippets core ${NGX_CORE_MODULES:-}
|
||||||
[ -n "$1" ] || return 1
|
combine_snippets http ${NGX_HTTP_MODULES:-}
|
||||||
n="$1" ; shift
|
combine_snippets mail ${NGX_MAIL_MODULES:-}
|
||||||
|
combine_snippets stream ${NGX_STREAM_MODULES:-}
|
||||||
for s ; do
|
|
||||||
[ -n "$s" ] || continue
|
|
||||||
|
|
||||||
old_name="snip/$n-$s.conf"
|
|
||||||
|
|
||||||
old_path="${merged_root}/${old_name}"
|
|
||||||
if ! [ -f "${old_path}" ] ; then
|
|
||||||
log "file ${old_name} is not found, skipping"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
new_path="/run/angie/${old_name}"
|
|
||||||
new_dir="${new_path%/*}"
|
|
||||||
[ -d "${new_dir}" ] || mkdir -p "${new_dir}"
|
|
||||||
|
|
||||||
smart_ln "${old_path}" "${new_path}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
combine_module_snippets core ${NGX_CORE_MODULES:-}
|
|
||||||
combine_module_snippets http ${NGX_HTTP_MODULES:-}
|
|
||||||
combine_module_snippets mail ${NGX_MAIL_MODULES:-}
|
|
||||||
combine_module_snippets stream ${NGX_STREAM_MODULES:-}
|
|
||||||
|
|
||||||
## merge remaining snippets
|
|
||||||
while read -r old_path ; do
|
|
||||||
[ -n "${old_path}" ] || continue
|
|
||||||
|
|
||||||
new_path=$(combine_remap_path "${old_path}")
|
|
||||||
[ -n "${new_path}" ] || exit 1
|
|
||||||
|
|
||||||
new_dir="${new_path%/*}"
|
|
||||||
[ -d "${new_dir}" ] || mkdir -p "${new_dir}"
|
|
||||||
|
|
||||||
smart_ln "${old_path}" "${new_path}"
|
|
||||||
done <<-EOF
|
|
||||||
$(
|
|
||||||
find "${merged_root}/snip/" ! -type d \
|
|
||||||
| grep -Ev -e "^${merged_root}/snip/(core|core_ev|http|mail|stream)-[^/]*\.conf\$" \
|
|
||||||
| sort -V
|
|
||||||
)
|
|
||||||
EOF
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -11,7 +11,7 @@ r=$?
|
|||||||
log_always '========================='
|
log_always '========================='
|
||||||
|
|
||||||
## cleanup after test
|
## cleanup after test
|
||||||
rm -f /run/angie/angie.pid
|
rm -f "${volume_root}/angie.pid"
|
||||||
|
|
||||||
if [ $r = 0 ] ; then
|
if [ $r = 0 ] ; then
|
||||||
log_always 'ready to run Angie'
|
log_always 'ready to run Angie'
|
||||||
|
30
scripts/angie-builtin-modules.sh
Executable file
30
scripts/angie-builtin-modules.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -f
|
||||||
|
|
||||||
|
conf_dir='/etc/angie'
|
||||||
|
conf_file="${conf_dir}/.none.conf"
|
||||||
|
pid_file='/run/angie/none.pid'
|
||||||
|
|
||||||
|
angie -g "error_log /dev/stderr warn; pid ${pid_file};" -c "${conf_file}" -t
|
||||||
|
r=$?
|
||||||
|
rm -f "${pid_file}"
|
||||||
|
[ $r -eq 0 ] || exit $r
|
||||||
|
|
||||||
|
t=$(mktemp) || exit $?
|
||||||
|
|
||||||
|
angie -c "${conf_file}" -m 2>&1 | tee "$t" >/dev/null
|
||||||
|
|
||||||
|
sed -En '/^ngx_(http|mail|stream)/d;/^ngx_(.+)_module$/{s//\1/;s/_filter$//;s/_/-/g;p}' < "$t" \
|
||||||
|
| sort -uV > "${conf_dir}/builtin.core"
|
||||||
|
|
||||||
|
for m in http mail stream ; do
|
||||||
|
sed -En '/^ngx_'"${m}"'_(.+)_module$/{s//\1/;s/_filter$//;s/_/-/g;p}' < "$t" \
|
||||||
|
| sort -uV > "${conf_dir}/builtin.$m"
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -f "$t" ; unset t
|
||||||
|
|
||||||
|
for m in core http mail stream ; do
|
||||||
|
echo "${conf_dir}/builtin.$m"
|
||||||
|
done \
|
||||||
|
| xargs -r ls -ld
|
Loading…
Reference in New Issue
Block a user