@@ -36,22 +36,14 @@ UE_NUMBERS=(3 2 1) # Subscribers from UE 3 to UE 1
3636APTVARS=" NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3737if ! command -v realpath & > /dev/null; then
3838 echo " Package \" coreutils\" not found, installing..."
39- sudo $APTVARS apt-get install -y coreutils
39+ sudo env $APTVARS apt-get install -y coreutils
4040fi
4141
4242SCRIPT_DIR=$( dirname " $( realpath " $0 " ) " )
4343cd " $SCRIPT_DIR "
4444
45- # Check if the YAML editor is installed, and install it if not
46- if ! command -v yq & > /dev/null; then
47- sudo " $SCRIPT_DIR /install_scripts/./install_yq.sh"
48- fi
49- # Check that the correct version of yq is installed
50- if ! yq --version 2> /dev/null | grep -q ' https://github\.com/mikefarah/yq' ; then
51- echo " ERROR: Detected an incompatible yq installation."
52- echo " Please ensure the Python yq is uninstalled with \" pip uninstall -y yq\" , then re-run this script."
53- exit 1
54- fi
45+ # Ensure the correct YAML editor is installed
46+ sudo " $SCRIPT_DIR /install_scripts/./ensure_consistent_yq.sh"
5547
5648echo " Parsing options.yaml..."
5749# Check if the YAML file exists, if not, set and save default values
@@ -350,39 +342,22 @@ if [[ "$OGSTUN_IPV6" == "null" || -z "$OGSTUN_IPV6" ]]; then
350342 exit 1
351343fi
352344
353- # Extract the first IPv4 address from a CIDR block by replacing the last octet with '.1'
354- # For example, 10.45.0.0/16 --> 10.45.0.1/16
355- grab_first_ipv4_address () {
356- local IP=$1
357- echo ${IP% .* } .1/${IP#*/ }
358- }
359-
360- # Extract the first IPv6 address from a CIDR block by replacing the suffix with '::1'.
361- # For example, 2001:db8:cafe::/48 --> 2001:db8:cafe::1/48
362- grab_first_ipv6_address () {
363- local IP=$1
364- echo ${IP%::* } ::1/${IP#*/ }
365- }
366-
367- # Remove the CIDR suffix from an IP address
368- # For example, 10.45.0.1/16 --> 10.45.0.1
369- remove_cidr_suffix () {
370- local IP=$1
371- echo ${IP%/* }
372- }
345+ if ! command -v python3 & > /dev/null; then
346+ echo " Python is not installed. Installing Python..."
347+ sudo apt-get update
348+ sudo apt-get install -y python3
349+ fi
373350
374351# Extract the first IPv4 and IPv6 addresses from the CIDR blocks
375- OGSTUN_IPV4_1=$( grab_first_ipv4_address " $OGSTUN_IPV4 " )
376- OGSTUN_IPV6_1=$( grab_first_ipv6_address " $OGSTUN_IPV6 " )
377- OGSTUN_IPV4_1_NO_CIDR=$( remove_cidr_suffix " $OGSTUN_IPV4_1 " )
378- OGSTUN_IPV6_1_NO_CIDR=$( remove_cidr_suffix " $OGSTUN_IPV6_1 " )
352+ OGSTUN_IPV4_1=" $( python3 install_scripts/fetch_nth_ip.py " $OGSTUN_IPV4 " 0) "
353+ OGSTUN_IPV6_1=" $( python3 install_scripts/fetch_nth_ip.py " $OGSTUN_IPV6 " 0) "
379354
380355if [ " $EXPOSE_AMF_OVER_HOSTNAME " = true ]; then
381356 AMF_IP=$( hostname -I | awk ' {print $1}' )
382357 set_configuration_server_ips $AMF_IP
383358 # Need an address for the gNodeB to bind to that is not the host IP.
384359 if [ " $IS_OPEN5GS_ON_HOST " = true ]; then
385- AMF_IP_BIND=$OGSTUN_IPV4_1_NO_CIDR
360+ AMF_IP_BIND=$OGSTUN_IPV4_1
386361 else
387362 AMF_IP_BIND=$AMF_IP
388363 fi
391366 AMF_IP_BIND=" 127.0.0.1"
392367fi
393368
394- set_configuration_session_gateways $OGSTUN_IPV4 $OGSTUN_IPV4_1_NO_CIDR $OGSTUN_IPV6 $OGSTUN_IPV6_1_NO_CIDR
369+ set_configuration_session_gateways $OGSTUN_IPV4 $OGSTUN_IPV4_1 $OGSTUN_IPV6 $OGSTUN_IPV6_1
395370
396371# Configure the Single Network Slice Selection Assistance Information (S-NSSAI)
397372set_snssai " $SST " " $SD "
@@ -413,6 +388,9 @@ configure_plmn_tac $MCC $MNC $TAC
413388
414389sudo ./install_scripts/network_config.sh
415390
391+ # Enable SCTP kernel module
392+ sudo ./install_scripts/enable_sctp.sh
393+
416394# Enable IPv4/IPv6 Forwarding
417395sudo sysctl -w net.ipv4.ip_forward=1
418396sudo sysctl -w net.ipv6.conf.all.forwarding=1
@@ -433,11 +411,20 @@ echo "Unregistering all subscribers in Open5GS database..."
433411
434412# Register the subscribers
435413for UE_NUMBER in " ${UE_NUMBERS[@]} " ; do
414+ UE_INDEX=$(( UE_NUMBER + 99 ))
415+ UE_IPV4=$( python3 install_scripts/fetch_nth_ip.py " $OGSTUN_IPV4 " " $UE_INDEX " )
416+ if [ $? -eq 0 ]; then
417+ IPV4_LINE=" --ipv4 $UE_IPV4 "
418+ else
419+ IPV4_LINE=" "
420+ fi
421+
436422 echo
437423 echo " Registering UE $UE_NUMBER ..."
424+
438425 # Fetch the UE's OPc, IMEI, IMSI, KEY, and NAMESPACE
439426 read -r UE_OPC UE_IMEI UE_IMSI UE_KEY UE_NAMESPACE < <( " $UE_CREDENTIAL_GENERATOR_SCRIPT " " $UE_NUMBER " " $PLMN " )
440- ./install_scripts/register_subscriber.sh --imsi " $UE_IMSI " --key " $UE_KEY " --opc " $UE_OPC " --apn " $DNN " --sst " $SST " --sd " $SD "
427+ ./install_scripts/register_subscriber.sh --imsi " $UE_IMSI " --key " $UE_KEY " --opc " $UE_OPC " --apn " $DNN " --sst " $SST " --sd " $SD " $IPV4_LINE
441428done
442429
443430# Restart Open5GS services to apply changes
0 commit comments