#!/bin/sh ## Angie: unset core variable unset ANGIE ANGIE_BPF_MAPS IEP_RETAIN_ENV=$(gobool_to_int "${IEP_RETAIN_ENV:-0}" 0) if [ "${IEP_RETAIN_ENV}" = 1 ] ; then log_always "NOT removing following variables:" sed -E '/^./s,^, ,' >&2 echo >&2 else __set="$-" set +e unset __env __env_print while read -r __env ; do [ -n "${__env}" ] || continue case "${__env}" in \'* | \"* ) log "skipping variable (malformed): ${__env}" >&2 continue ;; esac if [ "${IEP_DEBUG}" = 1 ] ; then __env_print="${__env}="$(printenv "${__env}") __env_print=$(env printf '%q' "${__env_print}") log_always "unsetting variable: ${__env_print}" else log "unsetting variable: ${__env}" fi unset "${__env}" done unset __env __env_print [ -z "${__set}" ] || set -"${__set}" unset __set fi <<-EOF $( set +e cat /proc/self/environ \ | sed -zEn '/^([^=]+).*$/s//\1/p' \ | xargs -0r printf '%q\n' \ | { ## retain variables defined in ".core_worker_env" configuration key ## (if it was specified somewhere in dictionaries - either yaml or json) f="${target_root}/j2cfg/core-worker-env.txt" [ -s "$f" ] || exec cat grep -Fxv -f "$f" } \ | { ## remove environment variables: ## 1. variables starting with "NGX" as they are used by configuration templates ## 2. variables containing "_SERVICE" or "_PORT" as they are came from ## container orchestration grep -E \ -e '^NGX' \ -e '_(SERVICE|PORT)' \ } \ | sort -uV ) EOF