9b49179faaa4832600a81f7985c3000c7a31cc79
[sim/o1-interface.git] / ntsimulator / deploy / o-ran-du-rel-18 / get_3gpp_yangs.sh
1 #!/bin/bash
2 #
3 # Copyright 2023 highstreet technologies GmbH and others
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Script which downloads the 3GPP YANG models in preparation for loading them in the O1 Simulator
18
19 DIRBIN="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
20 DIR_AVAILABLE_YANGS="$DIRBIN/available-yangs"
21 DIR_YANGS="$DIRBIN/yang"
22 FILE_DOWNLOADZIP="$DIRBIN/yangs.zip"
23 TMPFOLDER="/tmp/o1-yangs"
24 UNZIP=$(which unzip)
25 if [ -z "$UNZIP" ]; then
26     echo "unable to find unzip. please install."
27     exit 1
28 fi
29
30 # download
31 if [ ! -f "$FILE_DOWNLOADZIP" ]; then
32     wget -O "$FILE_DOWNLOADZIP" "https://forge.3gpp.org/rep/sa5/MnS/-/archive/Rel-18/MnS-Rel-18.zip?path=yang-models"
33 fi
34 if [ ! -d "$DIR_AVAILABLE_YANGS" ]; then
35     mkdir "$DIR_AVAILABLE_YANGS"
36 fi
37 # cleanup yang folders
38 rm -rf "$DIR_AVAILABLE_YANGS/"*
39 rm "$DIR_YANGS/*"
40 unzip -uj yangs.zip -d "$TMPFOLDER"
41 cp -r "$TMPFOLDER/"* "$DIR_AVAILABLE_YANGS/"
42
43 rm "$FILE_DOWNLOADZIP"
44
45 # fill yang folder
46 cp "$DIR_AVAILABLE_YANGS/"_3gpp-common*.yang "$DIR_YANGS"
47 cp "$DIR_AVAILABLE_YANGS/"ietf-*.yang "$DIR_YANGS/"
48
49 declare special_files=(
50     "_3gpp-5g-common-yang-types.yang"
51     "_3gpp-5gc-nrm-configurable5qiset.yang"
52     "_3gpp-nr-nrm-bwp.yang"
53     "_3gpp-nr-nrm-ep.yang"
54     "_3gpp-nr-nrm-gnbcucpfunction.yang"
55     "_3gpp-nr-nrm-gnbcuupfunction.yang"
56     "_3gpp-nr-nrm-gnbdufunction.yang"
57     "_3gpp-nr-nrm-nrsectorcarrier.yang"
58     "_3gpp-nr-nrm-nrcelldu.yang"
59 )
60
61 for file in "${special_files[@]}"
62 do
63    cp "$DIR_AVAILABLE_YANGS/$file" "$DIR_YANGS/"
64 done