forked from cnf-testsuite/open5gs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·65 lines (59 loc) · 1.93 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
_term() {
case "$command" in
ue)
echo "Deleting ue: nr-ue -c ue.yaml"
for x in $(./usr/local/bin/nr-cli -d); do
./usr/local/bin/nr-cli $x --exec "deregister switch-off"
done
echo "UEs switched off"
sleep 5
;;
*)
echo "It isn't necessary to perform any cleanup"
;;
esac
}
if [ $# -lt 1 ]
then
echo "Usage : $0 [gnb|ue]"
exit
fi
command=$1
trap _term SIGTERM
shift
case "$command" in
ue)
until [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]];
do
export ip=$(host -4 $GNB_HOSTNAME | awk '/has.*address/{print $NF; exit}')
echo "Waitting for GNB Host to come online"
sleep 5
done
export GNB_IP=$ip
echo "GNB_IP: $GNB_IP"
envsubst < /etc/ueransim/ue.yaml > ue.yaml
echo "Launching ue: nr-ue -c ue.yaml"
nr-ue -c ue.yaml $@ &
child=$!
wait "$child"
;;
gnb)
N2_BIND_IP=${N2_BIND_IP:-"$(ip addr show ${N2_IFACE} | grep -o 'inet [[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}'| cut -c 6-)"}
N3_BIND_IP=${N3_BIND_IP:-"$(ip addr show ${N3_IFACE} | grep -o 'inet [[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}'| cut -c 6-)"}
RADIO_BIND_IP=${RADIO_BIND_IP:-"$(ip addr show ${RADIO_IFACE} | grep -o 'inet [[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}\.[[:digit:]]\{1,3\}'| cut -c 6-)"}
AMF_IP=${AMF_IP:-"$(host -4 $AMF_HOSTNAME |awk '/has.*address/{print $NF; exit}')"}
export N2_BIND_IP N3_BIND_IP RADIO_BIND_IP AMF_IP
echo "N2_BIND_IP: $N2_BIND_IP"
echo "N3_BIND_IP: $N3_BIND_IP"
echo "RADIO_BIND_IP: $RADIO_BIND_IP"
echo "AMF_IP: $AMF_IP"
envsubst < /etc/ueransim/gnb.yaml > gnb.yaml
echo "Launching gnb: nr-gnb -c gnb.yaml"
nr-gnb -c gnb.yaml $@
;;
*) echo "unknown component $1 is not a component (gnb or ue). Running $@ as command"
$@
;;
esac