# prompt has been removed for easier Ctrl+C Ctrl+V
# please update the following information according to your configuration

INSTANCE=1
PREFIX='/usr/local/etc/oai'
sudo mkdir -m 0777 -p $PREFIX
cp ../../etc/amf.conf  $PREFIX

declare -A AMF_CONF

AMF_CONF[@INSTANCE@]=$INSTANCE
AMF_CONF[@PREFIX@]=$PREFIX
AMF_CONF[@PID_DIRECTORY@]='/var/run'

AMF_CONF[@MCC@]='208'
AMF_CONF[@MNC@]='95'
AMF_CONF[@REGION_ID@]='128'
AMF_CONF[@AMF_SET_ID@]='1'

AMF_CONF[@SERVED_GUAMI_MCC_0@]='208'
AMF_CONF[@SERVED_GUAMI_MNC_0@]='95'
AMF_CONF[@SERVED_GUAMI_REGION_ID_0@]='128'
AMF_CONF[@SERVED_GUAMI_AMF_SET_ID_0@]='1'
AMF_CONF[@SERVED_GUAMI_MCC_1@]='460'
AMF_CONF[@SERVED_GUAMI_MNC_1@]='11'
AMF_CONF[@SERVED_GUAMI_REGION_ID_1@]='10'
AMF_CONF[@SERVED_GUAMI_AMF_SET_ID_1@]='1'

AMF_CONF[@PLMN_SUPPORT_MCC@]='208'
AMF_CONF[@PLMN_SUPPORT_MNC@]='95'
AMF_CONF[@PLMN_SUPPORT_TAC@]='0xa000'
AMF_CONF[@SST_0@]='128'
AMF_CONF[@SD_0@]='128'
AMF_CONF[@SST_1@]='1'
AMF_CONF[@SD_1@]='1'

AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]='eth0'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]='eth0'

AMF_CONF[@EXTERNAL_AUSF@]='no'
AMF_CONF[@EXTERNAL_UDM@]='no'
AMF_CONF[@EXTERNAL_NRF@]='no'
AMF_CONF[@EXTERNAL_NSSF@]='no'
AMF_CONF[@USE_FQDN_DNS@]='no'
AMF_CONF[@USE_HTTP2@]='no'

AMF_CONF[@NF_REGISTRATION@]='no'
AMF_CONF[@SMF_SELECTION@]='no'

AMF_CONF[@SMF_INSTANCE_ID_0@]='1'
AMF_CONF[@SMF_IPV4_ADDR_0@]='192.168.22.208'
AMF_CONF[@SMF_HTTP_VERSION_0@]='v1'
AMF_CONF[@SMF_FQDN_0@]='oai-smf'
AMF_CONF[@SMF_INSTANCE_ID_1@]='2'
AMF_CONF[@SMF_IPV4_ADDR_1@]='192.168.22.207'
AMF_CONF[@SMF_HTTP_VERSION_1@]='v1'
AMF_CONF[@SMF_FQDN_1@]='oai-smf2'

AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.22.195'
AMF_CONF[@NRF_PORT@]='80'
AMF_CONF[@NRF_API_VERSION@]='v1'
AMF_CONF[@NRF_FQDN@]='oai-nrf'

AMF_CONF[@AUSF_IPV4_ADDRESS@]='192.168.22.199'
AMF_CONF[@AUSF_PORT@]='80'
AMF_CONF[@AUSF_API_VERSION@]='v1'
AMF_CONF[@AUSF_FQDN@]='oai-ausf'

AMF_CONF[@NSSF_IPV4_ADDRESS@]='192.168.22.214'
AMF_CONF[@NSSF_PORT@]='80'
AMF_CONF[@NSSF_API_VERSION@]='v1'
AMF_CONF[@NSSF_FQDN@]='oai-nssf'

AMF_CONF[@UDM_IPV4_ADDRESS@]='192.168.22.209'
AMF_CONF[@UDM_PORT@]='80'
AMF_CONF[@UDM_API_VERSION@]='v1'
AMF_CONF[@UDM_FQDN@]='oai-udm'

AMF_CONF[@NRF_SELECTION@]='no'
AMF_CONF[@INT_ALGO_LIST@]='[ "NIA0" , "NIA1" , "NIA2" ]'
AMF_CONF[@CIPH_ALGO_LIST@]='[ "NEA0" , "NEA1" , "NEA2" ]'

AMF_CONF[@MYSQL_SERVER@]='127.0.0.1'
AMF_CONF[@MYSQL_USER@]='root'
AMF_CONF[@MYSQL_PASS@]='linux'
AMF_CONF[@MYSQL_DB@]='oai_db'

for K in "${!AMF_CONF[@]}"; do 
  egrep -lRZ "$K" $PREFIX | xargs -0 -l sed -i -e "s|$K|${AMF_CONF[$K]}|g"
  ret=$?;[[ ret -ne 0 ]] && echo "Tried to replace $K with ${AMF_CONF[$K]}"
done
