From 8f754f84774a1c4279604556bb3bce3cf698e9a8 Mon Sep 17 00:00:00 2001 From: fstagni Date: Thu, 3 Dec 2020 17:06:02 +0100 Subject: [PATCH 1/2] load more than one DIRACSYSCONFIGFILE --- ConfigurationSystem/Client/LocalConfiguration.py | 12 ++++++++---- Core/scripts/dirac-install.py | 4 +++- .../Configuration/ConfigurationStructure/index.rst | 4 ++-- .../environment_variable_configuration.rst | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ConfigurationSystem/Client/LocalConfiguration.py b/ConfigurationSystem/Client/LocalConfiguration.py index ed054518db9..2cd7ff1c2b2 100755 --- a/ConfigurationSystem/Client/LocalConfiguration.py +++ b/ConfigurationSystem/Client/LocalConfiguration.py @@ -285,13 +285,17 @@ def __parseCommandLine(self): def __loadCFGFiles(self): """ - Load ~/.dirac.cfg - Load cfg files specified in addCFGFile calls - Load cfg files with come from the command line + Loads possibly several cfg files, in order: + 1. ~/.dirac.cfg + 2. cfg files pointed by DIRACSYSCONFIG env variable (comma-separated) + 3. cfg files specified in addCFGFile calls + 4. cfg files that come from the command line """ errorsList = [] if 'DIRACSYSCONFIG' in os.environ: - gConfigurationData.loadFile(os.environ['DIRACSYSCONFIG']) + diracSysConfigFiles = os.environ['DIRACSYSCONFIG'].replace(' ', '').split(',') + for diracSysConfigFile in diracSysConfigFiles: + gConfigurationData.loadFile(diracSysConfigFile) gConfigurationData.loadFile(os.path.expanduser("~/.dirac.cfg")) for fileName in self.additionalCFGFiles: gLogger.debug("Loading file %s" % fileName) diff --git a/Core/scripts/dirac-install.py b/Core/scripts/dirac-install.py index 44d7ede8c0a..346dc0d66d8 100755 --- a/Core/scripts/dirac-install.py +++ b/Core/scripts/dirac-install.py @@ -2188,7 +2188,9 @@ def createBashrc(): if cliParams.userEnvVariables: lines.extend(['# User-requested variables']) for envName, envValue in cliParams.userEnvVariables.items(): - lines.extend(['export %s=%s' % (envName, envValue)]) + lines.extend(['( echo $%s | grep -q $%s ) || export %s=$%s:$%s' % ( + envName, envValue, + envName, envName, envValue)]) lines.append('') f = open(bashrcFile, 'w') diff --git a/docs/source/AdministratorGuide/Configuration/ConfigurationStructure/index.rst b/docs/source/AdministratorGuide/Configuration/ConfigurationStructure/index.rst index c43fa6adf42..af35b2cec7b 100644 --- a/docs/source/AdministratorGuide/Configuration/ConfigurationStructure/index.rst +++ b/docs/source/AdministratorGuide/Configuration/ConfigurationStructure/index.rst @@ -69,7 +69,7 @@ in the order of preference of the option resolution: it will be interpreted as a configuration file, if the ``DIRAC_NO_CFG`` environment variable is not set. *Value of $DIRACSYSCONFIG environment variable* - if the DIRACSYSCONFIG variable is set, it should point to a cfg file (written in *CFG* format) + if the DIRACSYSCONFIG variable is set, it should point to a list of cfg file (written in *CFG* format), comma separated *$HOME/.dirac.cfg* This is the file in the user's home directory with the *CFG* format @@ -83,4 +83,4 @@ in the order of preference of the option resolution: The client needing a configuration option is first looking for it in the command line arguments. If the option is not found, the search continues in the user configuration file, then in the DIRAC installation configuration file and finally in the Configuration Service. These gives -a flexible mechanism of overriding global options by specific local settings. \ No newline at end of file +a flexible mechanism of overriding global options by specific local settings. diff --git a/docs/source/AdministratorGuide/ServerInstallations/environment_variable_configuration.rst b/docs/source/AdministratorGuide/ServerInstallations/environment_variable_configuration.rst index 8dcf3e3daf9..24b8fd3f0bc 100644 --- a/docs/source/AdministratorGuide/ServerInstallations/environment_variable_configuration.rst +++ b/docs/source/AdministratorGuide/ServerInstallations/environment_variable_configuration.rst @@ -35,7 +35,7 @@ DIRAC_VOMSES Can be set to point to a folder containing VOMSES information. See :ref:`multi_vo_dirac` DIRACSYSCONFIG - If set, its value should be (the full location on the file system of) a DIRAC cfg file, whose content will be used for the DIRAC configuration + If set, its value should be (the full locations on the file system of) one of more DIRAC cfg file(s) (comma separated), whose content will be used for the DIRAC configuration (see :ref:`dirac-cs-structure`) DISABLE_WATCHDOG_CPU_WALLCLOCK_CHECK From 55b5206556d7e25ff8e5a6e4aff0b9e1a2e4423e Mon Sep 17 00:00:00 2001 From: fstagni Date: Fri, 4 Dec 2020 10:39:45 +0100 Subject: [PATCH 2/2] reverse the order --- ConfigurationSystem/Client/LocalConfiguration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConfigurationSystem/Client/LocalConfiguration.py b/ConfigurationSystem/Client/LocalConfiguration.py index 2cd7ff1c2b2..a46f7ff5812 100755 --- a/ConfigurationSystem/Client/LocalConfiguration.py +++ b/ConfigurationSystem/Client/LocalConfiguration.py @@ -294,7 +294,7 @@ def __loadCFGFiles(self): errorsList = [] if 'DIRACSYSCONFIG' in os.environ: diracSysConfigFiles = os.environ['DIRACSYSCONFIG'].replace(' ', '').split(',') - for diracSysConfigFile in diracSysConfigFiles: + for diracSysConfigFile in reversed(diracSysConfigFiles): gConfigurationData.loadFile(diracSysConfigFile) gConfigurationData.loadFile(os.path.expanduser("~/.dirac.cfg")) for fileName in self.additionalCFGFiles: