2 ################################################################################
4 # Copyright 2019 highstreet technologies GmbH and others
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 ################################################################################
23 : ${SYSREPOCTL:=sysrepoctl}
24 : ${SYSREPOCFG:=sysrepocfg}
25 : ${SYSREPOCTL_ROOT_PERMS:=-o root:root -p 600}
26 : ${YANG_DIR:=@CMAKE_CURRENT_SOURCE_DIR@/yang/manager}
27 : ${STARTUP_DIR:=@CMAKE_CURRENT_SOURCE_DIR@/yang/startup}
29 is_yang_module_installed() {
32 $SYSREPOCTL -l | grep --count "^$module [^|]*|[^|]*| Installed .*$" > /dev/null
35 install_yang_module() {
38 if ! is_yang_module_installed $module; then
39 echo "- Installing module $module..."
40 $SYSREPOCTL -i -g ${YANG_DIR}/$module.yang $SYSREPOCTL_ROOT_PERMS
42 echo "- Module $module already installed."
46 uninstall_yang_module() {
49 if is_yang_module_installed $module; then
50 echo "- Uninstalling module $module..."
51 $SYSREPOCTL -u -m $module
53 echo "- Module $module is not installed."
57 enable_yang_module_feature() {
61 if ! $SYSREPOCTL -l | grep --count "^$module [^|]*|[^|]*|[^|]*|[^|]*|[^|]*|[^|]*|.* $feature.*$" > /dev/null; then
62 echo "- Enabling feature $feature in $module..."
63 $SYSREPOCTL -m $module -e $feature
65 echo "- Feature $feature in $module already enabled."
69 echo "- Installing network-topology-simulator..."
70 install_yang_module network-topology-simulator
72 echo "- Adding startup datastore in network-topology-simulator..."
73 $SYSREPOCFG -d startup -i $YANG_DIR/network-topology-simulator.xml -f xml network-topology-simulator