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 if [ "$skip_model" = true ]; then
62 echo "Skipping installation of excluded model $modelName..."
66 echo "Installing model: $model"
67 $SYSREPOCTL --install --yang=$model --owner=root:root --permissions=666
69 mapfile -t featureList < <(pyang -f listfeature $model)
71 if [ ${#featureList[@]} -eq 0 ]; then
72 echo "No features, nothing to do here..."
74 for feature in ${featureList[@]}
76 $SYSREPOCTL --feature-enable=$feature --module=$modelName
80 #if the YANG model contains only typedefs, we do not need to subscribe for datastore changes
81 isTypeOnly=$(pyang -f listfeature --is-type-only $model)
83 if [ "$isTypeOnly" == "False" ]; then
84 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
90 # Fix for the NETCONF notifications
91 echo "Fixing the NETCONF notifications..."
92 mkdir -p /var/run/sysrepo-subscriptions/ietf-crypto-types
94 echo "YANG models installation done!"