3 echo "Installing YANG models..."
9 : ${SYSREPOCTL:=sysrepoctl}
10 : ${SYSREPOCFG:=sysrepocfg}
11 : ${SYSREPOAPPSTART:=/opt/dev/sysrepo/build/examples/application_example}
13 declare -a excludedModules=()
17 pyang -f clearmust *.yang
19 mapfile -t modelList < <(pyang -f depend --depend-recurse *.yang)
23 echo "Removing config false from $model..."
24 sed -i '/config false;/d' $model
25 echo "Removing mandatory true from $model..."
26 sed -i '/mandatory true;/d' $model
29 if [ ${#modelList[@]} -eq 0 ]; then
30 echo "No models present, nothing to do..."
33 for model in ${modelList[@]}
35 modelName=${model%".yang"}
39 for excluded in ${excludedModules[@]}; do
40 if [ "$excluded" == "$modelName" ]; then
45 if [ "$skip_model" = true ]; then
46 echo "Skipping installation of excluded model $modelName..."
50 echo "Installing model: $model"
51 $SYSREPOCTL --install --yang=$model --owner=root:root --permissions=666
53 mapfile -t featureList < <(pyang -f listfeature $model)
55 if [ ${#featureList[@]} -eq 0 ]; then
56 echo "No features, nothing to do here..."
58 for feature in ${featureList[@]}
60 $SYSREPOCTL --feature-enable=$feature --module=$modelName
64 #if the YANG model contains only typedefs, we do not need to subscribe for datastore changes
65 isTypeOnly=$(pyang -f listfeature --is-type-only $model)
67 if [ "$isTypeOnly" == "False" ]; then
68 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
74 # Fix for the NETCONF notifications
75 echo "Fixing the NETCONF notifications..."
76 mkdir -p /var/run/sysrepo-subscriptions/ietf-crypto-types
78 echo "YANG models installation done!"