From 55d8353873db6633c087a5e47b6a0019b4e20dd9 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 1 Jun 2022 17:01:48 +0200 Subject: [PATCH] TT#177600 Move ngcpcfg specific configuration under /etc/ngcp-ngcpcfg The configuration files specific to the ngcpcfg tool should not be mixed with the site specific configuration, as that's rather confusing, more so when the actual ngcpcfg configuration contains references to the location of the ngcp-config dir itself, which makes it self-referential. Change-Id: I93f59e2ce3441c2c315956f68e22e4b2e9c839ac --- .github/workflows/tests.yml | 2 +- Makefile | 2 +- debian/ngcp-ngcpcfg.install | 2 +- debian/ngcp-ngcpcfg.maintscript | 1 + docs/ngcpcfg.txt | 20 +++++++++---------- etc/{ngcp-config => ngcp-ngcpcfg}/ngcpcfg.cfg | 2 +- functions/init | 12 +++++------ t/test_ngcpcfg.py | 2 +- 8 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 debian/ngcp-ngcpcfg.maintscript rename etc/{ngcp-config => ngcp-ngcpcfg}/ngcpcfg.cfg (97%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 180e1a8f..d3d236b8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,4 +27,4 @@ jobs: run: shellcheck --version - name: Shellcheck execution - run: shellcheck -P functions scripts/* functions/* etc/ngcp-config/ngcpcfg.cfg sbin/ngcpcfg + run: shellcheck -P functions scripts/* functions/* etc/ngcp-ngcpcfg/ngcpcfg.cfg sbin/ngcpcfg diff --git a/Makefile b/Makefile index bf6b8b00..791e5804 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ BASH_SCRIPTS = \ scripts/* \ functions/* \ - etc/ngcp-config/ngcpcfg.cfg \ + etc/ngcp-ngcpcfg/ngcpcfg.cfg \ sbin/ngcpcfg PERL_SCRIPTS = \ lib/NGCP/Template.pm \ diff --git a/debian/ngcp-ngcpcfg.install b/debian/ngcp-ngcpcfg.install index b9c5a661..45fb9fa8 100644 --- a/debian/ngcp-ngcpcfg.install +++ b/debian/ngcp-ngcpcfg.install @@ -1,4 +1,4 @@ -etc/ngcp-config/ngcpcfg.cfg etc/ngcp-config/ +etc/ngcp-ngcpcfg/ngcpcfg.cfg etc/ngcp-ngcpcfg/ functions/init usr/share/ngcp-ngcpcfg/functions/ functions/logs usr/share/ngcp-ngcpcfg/functions/ functions/main usr/share/ngcp-ngcpcfg/functions/ diff --git a/debian/ngcp-ngcpcfg.maintscript b/debian/ngcp-ngcpcfg.maintscript new file mode 100644 index 00000000..19ec6786 --- /dev/null +++ b/debian/ngcp-ngcpcfg.maintscript @@ -0,0 +1 @@ +mv_conffile /etc/ngcp-config/ngcpcfg.cfg /etc/ngcp-ngcpcfg/ngcpcfg.cfg 11.0.0.0+0~mr11.0.0.0 diff --git a/docs/ngcpcfg.txt b/docs/ngcpcfg.txt index 08ef0bf0..dbd51035 100644 --- a/docs/ngcpcfg.txt +++ b/docs/ngcpcfg.txt @@ -39,7 +39,7 @@ in _/etc/ngcp-config/network.yml_ *shared repository*:: Git repository shared amongst nodes inside a High Availability setup, as defined by the GLUSTERFS setting in -/etc/ngcp-config/ngcpcfg.d/shared_storage.cfg (requires ngcp-ngcpcfg-ha) and +/etc/ngcp-ngcpcfg/ngcpcfg.d/shared_storage.cfg (requires ngcp-ngcpcfg-ha) and being _/mnt/glusterfs_ by default *templates*:: template toolkit files with .tt2 suffix, found in @@ -75,20 +75,20 @@ any other .yml file _/etc/ngcp-config/_, defining important constant settings. This file is *not* supposed to be modified by the user (without having a very good reason). -* _/etc/ngcp-config/ngcpcfg.cfg_: main configuration file for ngcpcfg itself, -provides global variables used inside ngcpcfg and its helper scripts. This file -is *not* supposed to be modified by the user (without having a very good -reason). - * _/etc/ngcp-config/config.d/_: optional configuration directory with additional yml configuration files. Files inside this directory aren't supposed to be added or modified by the user. The purpose of this configuration directory is that software packages can enable/disable certain features through configuration options on demand. -* _/etc/ngcp-config/ngcpcfg.d/_: configuration directory for ngcpcfg itself. +* _/etc/ngcp-ngcpcfg/ngcpcfg.cfg_: main configuration file for ngcpcfg itself, +provides global variables used inside ngcpcfg and its helper scripts. This file +is *not* supposed to be modified by the user (without having a very good +reason). + +* _/etc/ngcp-ngcpcfg/ngcpcfg.d/_: configuration directory for ngcpcfg itself. Files with suffix '.cfg' inside this directory are sourced after -/etc/ngcp-config/ngcpcfg.cfg has been read. Files inside this directory are +/etc/ngcp-ngcpcfg/ngcpcfg.cfg has been read. Files inside this directory are *not* supposed to be modified by the user (without having a very good reason). [IMPORTANT] @@ -241,7 +241,7 @@ configuration file (/etc/foobar/baz) is available within the postbuild script. Syntax and layout of configuration files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -* _/etc/ngcp-config/ngcpcfg.cfg_: plain shell syntax style "key=value" entries +* _/etc/ngcp-ngcpcfg/ngcpcfg.cfg_: plain shell syntax style "key=value" entries * _central yml files_ (*.yml): YAML configuration syntax (see http://yaml.org/) @@ -738,7 +738,7 @@ Setup instructions Requirements for High Availability setups: * glusterfs is supposed to be set up working and deployed at /mnt/glusterfs - (as defined via /etc/ngcp-config/ngcpcfg.cfg) + (as defined via /etc/ngcp-ngcpcfg/ngcpcfg.cfg) * hosts are expected to be set up for automatic ssh login (ssh-keygen && ssh-copy-id) diff --git a/etc/ngcp-config/ngcpcfg.cfg b/etc/ngcp-ngcpcfg/ngcpcfg.cfg similarity index 97% rename from etc/ngcp-config/ngcpcfg.cfg rename to etc/ngcp-ngcpcfg/ngcpcfg.cfg index 837c58c2..503f13c3 100644 --- a/etc/ngcp-config/ngcpcfg.cfg +++ b/etc/ngcp-ngcpcfg/ngcpcfg.cfg @@ -1,4 +1,4 @@ -# Filename: /etc/ngcp-config/ngcpcfg.cfg +# Filename: /etc/ngcp-ngcpcfg/ngcpcfg.cfg # Purpose: main configuration file for ngcpcfg tools # Note: do not modify unless you have a really good reason to do so diff --git a/functions/init b/functions/init index 0e279884..ad5488b3 100644 --- a/functions/init +++ b/functions/init @@ -10,13 +10,13 @@ if [ -r "${NGCPCFG:-}" ] ; then # shellcheck disable=SC1090 . "${NGCPCFG:-}" else - if [ -r /etc/ngcp-config/ngcpcfg.cfg ] ; then + if [ -r /etc/ngcp-ngcpcfg/ngcpcfg.cfg ] ; then # shellcheck disable=SC1091 - . /etc/ngcp-config/ngcpcfg.cfg - log_debug "sourced configuration file /etc/ngcp-config/ngcpcfg.cfg" + . /etc/ngcp-ngcpcfg/ngcpcfg.cfg + log_debug "sourced configuration file /etc/ngcp-ngcpcfg/ngcpcfg.cfg" - if [ -d /etc/ngcp-config/ngcpcfg.d ] ; then - for file in /etc/ngcp-config/ngcpcfg.d/*.cfg ; do + if [ -d /etc/ngcp-ngcpcfg/ngcpcfg.d ] ; then + for file in /etc/ngcp-ngcpcfg/ngcpcfg.d/*.cfg ; do if [ -r "${file}" ]; then # shellcheck disable=SC1090 . "${file}" @@ -28,7 +28,7 @@ else log_error "Configuration pool locked. Please contact your distributor. Exiting." exit 1 else - log_error "Could not read configuration file /etc/ngcp-config/ngcpcfg.cfg. Exiting." + log_error "Could not read configuration file /etc/ngcp-ngcpcfg/ngcpcfg.cfg. Exiting." exit 1 fi fi diff --git a/t/test_ngcpcfg.py b/t/test_ngcpcfg.py index cf1ce6f8..c6b35154 100644 --- a/t/test_ngcpcfg.py +++ b/t/test_ngcpcfg.py @@ -21,7 +21,7 @@ def test_ngcpcfgcfg_ko(ngcpcfgcli): out = ngcpcfgcli(env={"NGCPCFG": "/doesnotexist"}) assert ( "Error: Could not read configuration file " - "/etc/ngcp-config/ngcpcfg.cfg. Exiting." in out.stderr + "/etc/ngcp-ngcpcfg/ngcpcfg.cfg. Exiting." in out.stderr ) assert out.returncode == 1