# 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@]='222'
AMF_CONF[@SD_0@]='123'
AMF_CONF[@SST_1@]='1'
AMF_CONF[@SD_1@]='12'

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

AMF_CONF[@EXTERNAL_AUSF@]='no'
AMF_CONF[@EXTERNAL_UDM@]='no'
AMF_CONF[@USE_FQDN_DNS@]='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.122.1'
AMF_CONF[@SMF_HTTP_VERSION_0@]='v1'
AMF_CONF[@SMF_FQDN_0@]='localhost'
AMF_CONF[@SMF_INSTANCE_ID_1@]='2'
AMF_CONF[@SMF_IPV4_ADDR_1@]='192.168.122.2'
AMF_CONF[@SMF_HTTP_VERSION_1@]='v1'
AMF_CONF[@SMF_FQDN_1@]='localhost'

AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
AMF_CONF[@NRF_PORT@]='80'
AMF_CONF[@NRF_API_VERSION@]='v1'
AMF_CONF[@NRF_FQDN@]='localhost'

AMF_CONF[@AUSF_IPV4_ADDRESS@]='192.168.1.23'
AMF_CONF[@AUSF_PORT@]='80'
AMF_CONF[@AUSF_API_VERSION@]='v1'
AMF_CONF[@AUSF_FQDN@]='localhost'

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

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
