AW2S image: install less packages, require mounted configuration file
This commit is contained in:
@@ -3,62 +3,18 @@
|
||||
set -uo pipefail
|
||||
|
||||
PREFIX=/opt/oai-gnb-aw2s
|
||||
ENABLE_X2=${ENABLE_X2:-yes}
|
||||
THREAD_PARALLEL_CONFIG=${THREAD_PARALLEL_CONFIG:-PARALLEL_SINGLE_THREAD}
|
||||
|
||||
# Based another env var, pick one template to use
|
||||
if [[ -v USE_VOLUMED_CONF ]]; then
|
||||
cp $PREFIX/etc/mounted.conf $PREFIX/etc/gnb.conf
|
||||
else
|
||||
echo "ERROR: No configuration file provided."
|
||||
echo "Please set USE_VOLUMED_CONF and mount a configuration file at $PREFIX/etc/mounted.conf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -v USE_NSA_TDD_MONO ]]; then cp $PREFIX/etc/gnb.nsa.tdd.conf $PREFIX/etc/gnb.conf; fi
|
||||
if [[ -v USE_SA_TDD_MONO ]]; then cp $PREFIX/etc/gnb.sa.tdd.conf $PREFIX/etc/gnb.conf; fi
|
||||
if [[ -v USE_SA_TDD_MONO_B2XX ]]; then cp $PREFIX/etc/gnb.sa.tdd.b2xx.conf $PREFIX/etc/gnb.conf; fi
|
||||
if [[ -v USE_SA_FDD_MONO ]]; then cp $PREFIX/etc/gnb.sa.fdd.conf $PREFIX/etc/gnb.conf; fi
|
||||
if [[ -v USE_SA_CU ]]; then cp $PREFIX/etc/gnb.sa.cu.conf $PREFIX/etc/gnb.conf; fi
|
||||
if [[ -v USE_SA_TDD_DU ]]; then cp $PREFIX/etc/gnb.sa.du.tdd.conf $PREFIX/etc/gnb.conf; fi
|
||||
if [[ -v USE_SA_NFAPI_VNF ]]; then cp $PREFIX/etc/gnb.sa.nfapi.vnf.conf $PREFIX/etc/gnb.conf; fi
|
||||
# Sometimes, the templates are not enough. We mount a conf file on $PREFIX/etc. It can be a template itself.
|
||||
if [[ -v USE_VOLUMED_CONF ]]; then cp $PREFIX/etc/mounted.conf $PREFIX/etc/gnb.conf; fi
|
||||
|
||||
# Default Parameters
|
||||
GNB_ID=${GNB_ID:-e00}
|
||||
NSSAI_SD=${NSSAI_SD:-ffffff}
|
||||
# AMF_IP_ADDRESS can be amf ip address of amf fqdn
|
||||
if [[ -v AMF_IP_ADDRESS ]] && [[ "${AMF_IP_ADDRESS}" =~ [a-zA-Z] ]] && [[ -z `getent hosts $AMF_IP_ADDRESS | awk '{print $1}'` ]]; then echo "not able to resolve AMF FQDN" && exit 1 ; fi
|
||||
[[ -v AMF_IP_ADDRESS ]] && [[ "${AMF_IP_ADDRESS}" =~ [a-zA-Z] ]] && AMF_IP_ADDRESS=$(getent hosts $AMF_IP_ADDRESS | awk '{print $1}')
|
||||
|
||||
# Only this template will be manipulated
|
||||
CONFIG_FILES=`ls $PREFIX/etc/gnb.conf || true`
|
||||
|
||||
for c in ${CONFIG_FILES}; do
|
||||
# Sometimes templates have no pattern to be replaced.
|
||||
if ! grep -oP '@[a-zA-Z0-9_]+@' ${c}; then
|
||||
echo "Configuration is already set"
|
||||
break
|
||||
fi
|
||||
|
||||
# grep variable names (format: ${VAR}) from template to be rendered
|
||||
VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs)
|
||||
|
||||
# create sed expressions for substituting each occurrence of ${VAR}
|
||||
# with the value of the environment variable "VAR"
|
||||
EXPRESSIONS=""
|
||||
for v in ${VARS}; do
|
||||
NEW_VAR=`echo $v | sed -e "s#@##g"`
|
||||
if [[ "${!NEW_VAR}x" == "x" ]]; then
|
||||
echo "Error: Environment variable '${NEW_VAR}' is not set." \
|
||||
"Config file '$(basename $c)' requires all of $VARS."
|
||||
exit 1
|
||||
fi
|
||||
EXPRESSIONS="${EXPRESSIONS};s|${v}|${!NEW_VAR}|g"
|
||||
done
|
||||
EXPRESSIONS="${EXPRESSIONS#';'}"
|
||||
|
||||
# render template and inline replace config file
|
||||
sed -i "${EXPRESSIONS}" ${c}
|
||||
|
||||
echo "=================================="
|
||||
echo "== Configuration file: ${c}"
|
||||
cat ${c}
|
||||
done
|
||||
echo "=================================="
|
||||
echo "== Configuration file:"
|
||||
cat $PREFIX/etc/enb.conf
|
||||
|
||||
# enable printing of stack traces on assert
|
||||
export gdbStacks=1
|
||||
|
||||
Reference in New Issue
Block a user