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 MAKE_PATH="$HOME/build/o1"
26 NETCONF_PATH="$HOME/build/o1/netconf"
27 SYSREPOCTL_PATH="$NETCONF_PATH/sysrepo/build/sysrepoctl"
28 YANG_PATH="$HOME/build/o1/yang"
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"
56 #functions definitions
57 #TBD: install only mandatory packages
59 #install pre-requisite packages
61 prerequisite_netconf() {
64 $SUDO apt-get install -y jq \
85 log_success " $1 INSTALLATION DONE"
87 log_error " $1 INSTALLATION FAILED "
93 #install netconf libraries
94 install_netconf_lib() {
96 #with sudo we can not create new user so we need to create it manually using
99 #$SUDO adduser --system netconf && \
100 # echo "netconf:netconf" | chpasswd
102 #$SUDO mkdir -p /home/netconf/.ssh && \
104 # ssh-keygen -t dsa -P '' -f /home/netconf/.ssh/id_dsa && \
105 # cat /home/netconf/.ssh/id_dsa.pub > /home/netconf/.ssh/authorized_keys
107 if [[ "$CLEANUP" == "cleanup" ]]; then
109 log_warning "DELETED $NETCONF_PATH"
112 mkdir -p $NETCONF_PATH
115 cd $NETCONF_PATH && \
116 git clone -b v0-7 --depth 1 http://git.libssh.org/projects/libssh.git && \
117 cd libssh; mkdir build; cd build && \
122 check_ret "LIBSSH" "$?"
125 cd $NETCONF_PATH && \
126 git clone -b v1.0.184 --depth 1 https://github.com/CESNET/libyang.git && \
127 cd libyang && mkdir build && cd build && \
128 cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF \
129 -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_BUILD_TESTS=OFF .. && \
131 $SUDO make install && \
134 check_ret "LIBYANG" "$?"
137 cd $NETCONF_PATH && \
138 git clone -b v1.4.70 --depth 1 https://github.com/sysrepo/sysrepo.git && \
139 cd sysrepo && sed -i -e 's/2000/30000/g;s/5000/30000/g' src/common.h.in && \
140 mkdir build && cd build && \
141 cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_PYTHON_BINDINGS=OFF \
142 -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_TESTS=OFF \
143 -DREPOSITORY_LOC:PATH=/etc/sysrepo .. && \
145 $SUDO make install && $SUDO make sr_clean && \
148 check_ret "SYSREPO" "$?"
151 cd $NETCONF_PATH && \
152 git clone -b v1.1.36 --depth 1 https://github.com/CESNET/libnetconf2.git && \
153 cd libnetconf2 && mkdir build && cd build && \
154 cmake -DCMAKE_BUILD_TYPE:String="Debug" -DENABLE_BUILD_TESTS=OFF .. && \
156 $SUDO make install && \
159 check_ret "LIBNETCONF2" "$?"
162 cd $NETCONF_PATH && \
163 git clone -b v1.1.53 --depth 1 https://github.com/CESNET/Netopeer2.git && \
164 cd Netopeer2 && mkdir build && cd build && \
165 cmake -DCMAKE_BUILD_TYPE:String="Debug" -DNP2SRV_DATA_CHANGE_TIMEOUT=30000 \
166 -DNP2SRV_DATA_CHANGE_WAIT=OFF .. && \
168 $SUDO make install -d
169 check_ret "NETOPEER2" "$?"
175 install_yang_module() {
176 $SYSREPOCTL_PATH -i "$YANG_PATH/o-ran-sc-du-alarm-v1.yang"
180 #wait for ack of user
183 read -n 1 -p "Press any key to continue, or CTRL+C to abort" mainmenuinout
187 #show help for user to provide valid input
189 echo "use -c option for cleanup"
190 echo "ex : $./install_lib.sh -c"
196 unset INSTALL CLEANUP
204 -c) CLEANUP="cleanup"
212 [ "${1:-}" = "--" ] && shift
214 log_success "MAIN: PARSING OF ARGUMENT DONE"
218 #start execution / function calls
219 if [[ "$#" -ge 2 ]] ; then
220 log_error " NUMBER OF PARAMETER : $# "
230 #yang installation yet not enabled
231 if [[ "$INSTALL" == "yang" ]] ; then
233 log " YANG INSTALLATION PROCESSING "
235 log_success " YANG INSTALLATION DONE "
240 log_success " SCRIPT COMPLETED"
243 #**********************************************************************
245 #**********************************************************************