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 ################################################################################
19 echo "Installing YANG models..."
25 : ${SYSREPOCTL:=sysrepoctl}
26 : ${SYSREPOCFG:=sysrepocfg}
27 : ${SYSREPOAPPSTART:=/opt/dev/sysrepo/build/examples/application_example}
29 declare -a excludedModules=()
33 pyang -f clearmust *.yang
35 mapfile -t modelList < <(pyang -f depend --depend-recurse *.yang)
39 echo "Removing config false from $model..."
40 sed -i '/config false;/d' $model
41 echo "Removing mandatory true from $model..."
42 sed -i '/mandatory true;/d' $model
45 if [ ${#modelList[@]} -eq 0 ]; then
46 echo "No models present, nothing to do..."
49 for model in ${modelList[@]}
51 modelName=${model%".yang"}
55 for excluded in ${excludedModules[@]}; do
56 if [ "$excluded" == "$modelName" ]; then
61 isSubmoduleOnly=$(pyang -f submodule --submodule-only $model)
63 if [ "$isSubmoduleOnly" == "True" ]; then
64 echo "Skipping installation of model $modelName because it only contains submodules..."
68 if [ "$skip_model" = true ]; then
69 echo "Skipping installation of excluded model $modelName..."
73 echo "Installing model: $model"
74 $SYSREPOCTL --install --yang=$model --owner=root:root --permissions=666
76 mapfile -t featureList < <(pyang -f listfeature $model)
78 if [ ${#featureList[@]} -eq 0 ]; then
79 echo "No features, nothing to do here..."
81 for feature in ${featureList[@]}
83 $SYSREPOCTL --feature-enable=$feature --module=$modelName
87 #if the YANG model contains only typedefs, we do not need to subscribe for datastore changes
88 isTypeOnly=$(pyang -f listfeature --is-type-only $model)
90 if [ "$isTypeOnly" == "False" ]; then
91 printf "\n[program:$modelName]\ncommand=/opt/dev/sysrepo/build/examples/application_example $modelName\nautorestart=false\nredirect_stderr=true\nstartretries=1\npriority=4\n" >> /etc/supervisord.conf
97 # Fix for the NETCONF notifications
98 echo "Fixing the NETCONF notifications..."
99 mkdir -p /var/run/sysrepo-subscriptions/ietf-crypto-types
101 echo "YANG models installation done!"