mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-01 13:23:01 +02:00
confd: follow-up to 7d9257f
First, actually remove setup.sh. No reason to have the old version lingering in the repo confusing devs. Also simplify script heading dropping previous netopeer2 text and distilling the comment before sourcing the .inc file. Silence the install/update, dropping -v -- no need to be overly verbose now that we now the new yang loader works at build time. Crucially -- fix a bug in UPDATE_MODULE(), missing closing ' Simplify naming and location of .inc files. No need for the long filenames, or the new directory, the directory name gives plenty of context. Add reminder of duplicate infix-interfaces.yang in .inc files -- this duplication is unfortunate and we should try to fix this better. We will forget to update one or the other any day ... Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
# This is based on scripts/setup.sh from Netopeer2/libnetconf2
|
||||
# env variables NP2_MODULE_DIR, NP2_MODULE_PERMS must be defined and NP2_MODULE_OWNER, NP2_MODULE_GROUP will be used if
|
||||
# defined when executing this script!
|
||||
#if [ -z "$NP2_MODULE_DIR" -o -z "$NP2_MODULE_PERMS" ]; then
|
||||
# echo "Required environment variables not defined!"
|
||||
# exit 1
|
||||
#fi
|
||||
#
|
||||
#set -x
|
||||
|
||||
|
||||
# Source the provided file, which is expected to contain the list of YANG modules and their features.
|
||||
# This file, specified by the first argument to the script ($1), is sourced to populate the MODULES
|
||||
# array with the modules and their respective features to be processed by this script.
|
||||
# The file typically includes definitions in the form of module@revision with optional features to enable,
|
||||
# e.g., module@revision -e feature1 -e feature2.
|
||||
source $1
|
||||
# Source the include file, which contain the list of YANG models and
|
||||
# their respective enabled features in a MODULES array.
|
||||
# Example:
|
||||
# MODULES=("module@revision -e feature1 -e feature2")
|
||||
source "$1"
|
||||
|
||||
# optional env variable override
|
||||
if [ -n "$SYSREPOCTL_EXECUTABLE" ]; then
|
||||
SYSREPOCTL="$SYSREPOCTL_EXECUTABLE"
|
||||
# avoid problems with sudo PATH
|
||||
elif [ `id -u` -eq 0 ] && [ -n "$USER" ] && [ `command -v su` ]; then
|
||||
SYSREPOCTL=`command -v sysrepoctl -l $USER`
|
||||
SYSREPOCTL=`command sysrepoctl -l $USER`
|
||||
else
|
||||
SYSREPOCTL=`command -v sysrepoctl`
|
||||
SYSREPOCTL=`command sysrepoctl`
|
||||
fi
|
||||
|
||||
MODDIR=${SEARCH_PATH}
|
||||
@@ -48,8 +41,8 @@ INSTALL_MODULE_CMD() {
|
||||
}
|
||||
|
||||
UPDATE_MODULE() {
|
||||
CMD="'$SYSREPOCTL' -U $MODDIR/$1 -s '$MODDIR -v2"
|
||||
eval $CMD
|
||||
CMD="'$SYSREPOCTL' -U $MODDIR/$1 -s '$MODDIR' -v2"
|
||||
eval "$CMD"
|
||||
local rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
exit $rc
|
||||
@@ -87,6 +80,7 @@ for i in "${MODULES[@]}"; do
|
||||
SCTL_MODULE=`echo "$SCTL_MODULES" | grep "^$name \+|[^|]*| I"`
|
||||
if [ -z "$SCTL_MODULE" ]; then
|
||||
# prepare command to install module with all its features
|
||||
echo "*** Installing YANG model $name ..."
|
||||
INSTALL_MODULE_CMD "$i"
|
||||
continue
|
||||
fi
|
||||
@@ -96,6 +90,7 @@ for i in "${MODULES[@]}"; do
|
||||
if [ "$sctl_revision" \< "$revision" ]; then
|
||||
# update module without any features
|
||||
file=`echo "$i" | cut -d' ' -f 1`
|
||||
echo "*** Updating YANG model $name ($file) ..."
|
||||
UPDATE_MODULE "$file"
|
||||
fi
|
||||
|
||||
@@ -104,6 +99,7 @@ for i in "${MODULES[@]}"; do
|
||||
sctl_perms=`echo "$SCTL_MODULE" | sed 's/\([^|]*|\)\{4\} \([^ ]*\).*/\2/'`
|
||||
if [ "$sctl_perms" != "$PERMS" ]; then
|
||||
# change permissions/owner
|
||||
echo "*** Changing YANG model $name permissions ..."
|
||||
CHANGE_PERMS "$name"
|
||||
fi
|
||||
|
||||
@@ -128,8 +124,10 @@ for i in "${MODULES[@]}"; do
|
||||
features=`echo "$features" | sed 's/[^[:space:]]* \(.*\)/\1/'`
|
||||
done
|
||||
done
|
||||
|
||||
# install all the new modules
|
||||
if [ ! -z "${CMD_INSTALL}" ]; then
|
||||
if [ -n "${CMD_INSTALL}" ]; then
|
||||
printf "*** Installing YANG models ...\n%s" "$CMD_INSTALL"
|
||||
eval $CMD_INSTALL
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user