Skip to content

Commit

Permalink
confd: follow-up to 7d9257f
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
troglobit committed Jun 20, 2024
1 parent 5de9fd8 commit 3c8c109
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 219 deletions.
4 changes: 2 additions & 2 deletions package/confd/confd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ COMMON_SYSREPO_ENV = \

define CONFD_INSTALL_YANG_MODULES
$(COMMON_SYSREPO_ENV) \
$(BR2_EXTERNAL_INFIX_PATH)/utils/sysrepo-load-modules.sh $(@D)/yang-setup/yang-modules-confd.inc
$(BR2_EXTERNAL_INFIX_PATH)/utils/sysrepo-load-modules.sh $(@D)/yang/confd.inc
endef

ifeq ($(BR2_PACKAGE_PODMAN),y)
define CONFD_INSTALL_YANG_MODULES_CONTAINERS
$(COMMON_SYSREPO_ENV) \
$(BR2_EXTERNAL_INFIX_PATH)/utils/sysrepo-load-modules.sh $(@D)/yang-setup/yang-modules-containers.inc
$(BR2_EXTERNAL_INFIX_PATH)/utils/sysrepo-load-modules.sh $(@D)/yang/containers.inc
endef
endif

Expand Down
193 changes: 0 additions & 193 deletions src/confd/scripts/setup.sh

This file was deleted.

4 changes: 0 additions & 4 deletions src/confd/yang-setup/yang-modules-containers.inc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- sh -*-
# REMEMBER TO UPDATE infix-interfaces ALSO IN containers.inc
MODULES=(
"[email protected] -e authentication -e local-users -e ntp -e ntp-udp-port -e timezone-name"
"[email protected]"
Expand Down Expand Up @@ -45,4 +47,4 @@ MODULES=(
"[email protected] -e server-ident-raw-public-key -e server-ident-x509-cert"
"[email protected]"
"[email protected] -e vlan-filtering"
)
)
6 changes: 6 additions & 0 deletions src/confd/yang/containers.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- sh -*-
# REMEMBER TO UPDATE infix-interfaces ALSO IN confd.inc
MODULES=(
"[email protected] -e vlan-filtering -e containers"
"[email protected]"
)
36 changes: 17 additions & 19 deletions utils/sysrepo-load-modules.sh
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 3c8c109

Please sign in to comment.