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 -b v0-7 --depth 1 http://git.libssh.org/projects/libssh.git && \
101 cd libssh; mkdir build; cd build && \
106 check_ret "LIBSSH" "$?"
109 cd $NETCONF_PATH && \
110 git clone --single-branch --branch v1.7.14 https://github.com/DaveGamble/cJSON.git && \
112 mkdir build && cd build && \
113 cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off && \
115 $SUDO make install && \
117 check_ret "LIBJSON" "$?"
120 cd $NETCONF_PATH && \
121 git clone --single-branch --branch curl-7_72_0 https://github.com/curl/curl.git &&\
123 mkdir build && cd build && \
124 cmake -DBUILD_TESTING=OFF .. && \
126 $SUDO make install && \
128 check_ret "LIBCURL" "$?"
131 cd $NETCONF_PATH && \
132 git clone -b v1.0.184 --depth 1 https://github.com/CESNET/libyang.git && \
133 cd libyang && mkdir build && cd build && \
134 cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF \
135 -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_BUILD_TESTS=OFF .. && \
137 $SUDO make install && \
140 check_ret "LIBYANG" "$?"
143 cd $NETCONF_PATH && \
144 git clone -b v1.4.70 --depth 1 https://github.com/sysrepo/sysrepo.git && \
145 cd sysrepo && sed -i -e 's/2000/30000/g;s/5000/30000/g' src/common.h.in && \
146 mkdir build && cd build && \
147 cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF \
148 -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_TESTS=OFF \
149 -DREPOSITORY_LOC:PATH=/etc/sysrepo .. && \
151 $SUDO make install && $SUDO make sr_clean && \
154 check_ret "SYSREPO" "$?"
157 cd $NETCONF_PATH && \
158 git clone -b v1.1.36 --depth 1 https://github.com/CESNET/libnetconf2.git && \
159 cd libnetconf2 && mkdir build && cd build && \
160 cmake -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_BUILD_TESTS=OFF .. && \
162 $SUDO make install && \
165 check_ret "LIBNETCONF2" "$?"
168 cd $NETCONF_PATH && \
169 git clone -b v1.1.53 --depth 1 https://github.com/CESNET/Netopeer2.git && \
170 cd Netopeer2 && mkdir build && cd build && \
171 cmake -DCMAKE_BUILD_TYPE:String="Debug" -DNP2SRV_DATA_CHANGE_TIMEOUT=30000 \
172 -DNP2SRV_DATA_CHANGE_WAIT=OFF .. && \
174 $SUDO make install -d
175 check_ret "NETOPEER2" "$?"
181 install_yang_module() {
182 sysrepoctl -i "$YANG_PATH/o-ran-sc-odu-alarm-v1.yang"
183 sysrepoctl -i "$YANG_PATH/o-ran-sc-odu-interface-v1.yang"
184 sysrepocfg --import="$CONFIG_PATH/$STARTUP_CONFIG" --datastore startup --module o-ran-sc-odu-interface-v1
188 #wait for ack of user
191 read -n 1 -p "Press any key to continue, or CTRL+C to abort" mainmenuinout
195 #show help for user to provide valid input
197 echo "use -c option for cleanup"
198 echo "ex : $./install_lib_O1.sh -c"
204 unset INSTALL CLEANUP
212 -c) CLEANUP="cleanup"
220 [ "${1:-}" = "--" ] && shift
222 log_success "MAIN: PARSING OF ARGUMENT DONE"
226 #start execution / function calls
227 if [[ "$#" -ge 3 ]] ; then
228 log_error " NUMBER OF PARAMETER : $# "
238 #yang installation yet not enabled
239 if [[ "$INSTALL" == "yang" ]] ; then
241 log " YANG INSTALLATION PROCESSING "
243 log_success " YANG INSTALLATION DONE "
248 log_success " SCRIPT COMPLETED"
251 #**********************************************************************
253 #**********************************************************************