1 ################################################################################
2 # Copyright (c) [2020-2021] [HCL Technologies Ltd] #
4 # Licensed under the Apache License, Version 2.0 (the "License"); #
5 # you may not use this file except in compliance with the License. #
6 # You may obtain a copy of the License at #
8 # http://www.apache.org/licenses/LICENSE-2.0 #
10 # Unless required by applicable law or agreed to in writing, software #
11 # distributed under the License is distributed on an "AS IS" BASIS, #
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13 # See the License for the specific language governing permissions and #
14 # limitations under the License. #
15 ################################################################################
19 # Pre-requisite script for installing Netconf Libraries
20 # and compiling the O1 module
24 HOME="$CURRENT_PATH/../.."
25 NETCONF_PATH="$HOME/build/netconf"
26 YANG_PATH="$HOME/build/yang"
27 CONFIG_PATH="$HOME/build/config"
28 STARTUP_CONFIG="startup_config.xml"
37 echo -e "\e[1;31m ***** $1 ***** \e[0m"
42 echo -e "\e[1;35m ***** $1 ***** \e[0m"
47 echo -e "\e[1;32m ***** $1 ***** \e[0m"
54 #install pre-requisite packages
56 prerequisite_netconf() {
59 $SUDO apt-get install -y jq \
80 log_success " $1 INSTALLATION DONE"
82 log_error " $1 INSTALLATION FAILED "
88 #install netconf libraries
89 install_netconf_lib() {
91 if [[ "$CLEANUP" == "cleanup" ]]; then
93 log_warning "DELETED $NETCONF_PATH"
96 mkdir -p $NETCONF_PATH
100 git clone -c http.sslverify=false --depth 1 https://github.com/libssh/libssh-mirror.git && \
101 mv libssh-mirror libssh && \
102 cd libssh; mkdir build; cd build && \
107 check_ret "LIBSSH" "$?"
110 cd $NETCONF_PATH && \
111 git clone --single-branch --branch v1.7.14 https://github.com/DaveGamble/cJSON.git && \
113 mkdir build && cd build && \
114 cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off && \
116 $SUDO make install && \
118 check_ret "LIBJSON" "$?"
121 cd $NETCONF_PATH && \
122 git clone --single-branch --branch curl-7_72_0 https://github.com/curl/curl.git &&\
124 mkdir build && cd build && \
125 cmake -DBUILD_TESTING=OFF .. && \
127 $SUDO make install && \
129 check_ret "LIBCURL" "$?"
132 cd $NETCONF_PATH && \
133 git clone -b v1.0.184 --depth 1 https://github.com/CESNET/libyang.git && \
134 cd libyang && mkdir build && cd build && \
135 cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF \
136 -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_BUILD_TESTS=OFF .. && \
138 $SUDO make install && \
141 check_ret "LIBYANG" "$?"
144 cd $NETCONF_PATH && \
145 git clone -b v1.4.70 --depth 1 https://github.com/sysrepo/sysrepo.git && \
146 cd sysrepo && sed -i -e 's/2000/30000/g;s/5000/30000/g' src/common.h.in && \
147 mkdir build && cd build && \
148 cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF \
149 -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_TESTS=OFF \
150 -DREPOSITORY_LOC:PATH=/etc/sysrepo .. && \
152 $SUDO make install && $SUDO make sr_clean && \
155 check_ret "SYSREPO" "$?"
158 cd $NETCONF_PATH && \
159 git clone -b v1.1.36 --depth 1 https://github.com/CESNET/libnetconf2.git && \
160 cd libnetconf2 && mkdir build && cd build && \
161 cmake -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_BUILD_TESTS=OFF .. && \
163 $SUDO make install && \
166 check_ret "LIBNETCONF2" "$?"
169 cd $NETCONF_PATH && \
170 git clone -b v1.1.53 --depth 1 https://github.com/CESNET/Netopeer2.git && \
171 cd Netopeer2 && mkdir build && cd build && \
172 cmake -DCMAKE_BUILD_TYPE:String="Debug" -DNP2SRV_DATA_CHANGE_TIMEOUT=30000 \
173 -DNP2SRV_DATA_CHANGE_WAIT=OFF .. && \
175 $SUDO make install -d
176 check_ret "NETOPEER2" "$?"
182 install_yang_module() {
183 sysrepoctl -i "$YANG_PATH/o-ran-sc-odu-alarm-v1.yang"
184 sysrepoctl -i "$YANG_PATH/o-ran-sc-odu-interface-v1.yang"
185 sysrepocfg --import="$CONFIG_PATH/$STARTUP_CONFIG" --datastore startup --module o-ran-sc-odu-interface-v1
189 #wait for ack of user
192 read -n 1 -p "Press any key to continue, or CTRL+C to abort" mainmenuinout
196 #show help for user to provide valid input
198 echo "use -c option for cleanup"
199 echo "ex : $./install_lib_O1.sh -c"
205 unset INSTALL CLEANUP
213 -c) CLEANUP="cleanup"
221 [ "${1:-}" = "--" ] && shift
223 log_success "MAIN: PARSING OF ARGUMENT DONE"
227 #start execution / function calls
228 if [[ "$#" -ge 3 ]] ; then
229 log_error " NUMBER OF PARAMETER : $# "
239 #yang installation yet not enabled
240 if [[ "$INSTALL" == "yang" ]] ; then
242 log " YANG INSTALLATION PROCESSING "
244 log_success " YANG INSTALLATION DONE "
249 log_success " SCRIPT COMPLETED"
252 #**********************************************************************
254 #**********************************************************************