|
Alain Reguera Delgado |
06ab0f |
tcar_setModuleEnvironment.sh(1)
|
|
Alain Reguera Delgado |
06ab0f |
===============================
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Name
|
|
Alain Reguera Delgado |
06ab0f |
----
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
tcar_setModuleEnvironment.sh - Initiate module environments.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Synopsis
|
|
Alain Reguera Delgado |
06ab0f |
--------
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
tcar_setModuleEnvironment -m "MODULE_NAME" -t "MODULE_TYPE" "${@}"
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Description
|
|
Alain Reguera Delgado |
06ab0f |
-----------
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Inside the centos-art.sh script, from version 0.5 on, all
|
|
Alain Reguera Delgado |
06ab0f |
functionalities have been rewritten to fit a modular design. This
|
|
Alain Reguera Delgado |
06ab0f |
modular design is conceived with the idea of loading and
|
|
Alain Reguera Delgado |
06ab0f |
executing only the functions that are absolutely required for the
|
|
Alain Reguera Delgado |
06ab0f |
current task.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Inside the centos-art.sh script there are two kinds of functions,
|
|
Alain Reguera Delgado |
06ab0f |
which are "global functions" and "module-specific functions." The
|
|
Alain Reguera Delgado |
06ab0f |
global functions are loaded in the very beginning of centos-art.sh
|
|
Alain Reguera Delgado |
06ab0f |
script and remain in memory for you to use whenever you need it,
|
|
Alain Reguera Delgado |
06ab0f |
using a regular function call syntax. The module-specific
|
|
Alain Reguera Delgado |
06ab0f |
functions, on the other hand, are only loaded when they are needed
|
|
Alain Reguera Delgado |
06ab0f |
and they are removed from memory once the task they were created
|
|
Alain Reguera Delgado |
06ab0f |
to perform is over. To load module-specific functions inside the
|
|
Alain Reguera Delgado |
06ab0f |
centos-art.sh script, you use the tcar_setModuleEnvironment
|
|
Alain Reguera Delgado |
06ab0f |
function as described in the USAGE section, above.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Each time you execute the tcar_setModuleEnvironment function, you
|
|
Alain Reguera Delgado |
06ab0f |
are creating a new module environment. Module environments are
|
|
Alain Reguera Delgado |
06ab0f |
logical space where you can develop solutions for specific
|
|
Alain Reguera Delgado |
06ab0f |
problems. These spaces are made available by creating a module
|
|
Alain Reguera Delgado |
06ab0f |
directory structure inside the CentOS artwork repository,
|
|
Alain Reguera Delgado |
06ab0f |
specifically under the Automation/Modules/ location. Inside this
|
|
Alain Reguera Delgado |
06ab0f |
location, you can find the different types of modules we mentioned
|
|
Alain Reguera Delgado |
06ab0f |
earlier (top-module, sub-module, and sib-module), based on the
|
|
Alain Reguera Delgado |
06ab0f |
levels deep they are stored in the file system.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
The module directory structure, as interpreted by
|
|
Alain Reguera Delgado |
06ab0f |
tcar_setModuleEnvironment has the following form:
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
.Module's directory structure.
|
|
Alain Reguera Delgado |
06ab0f |
======================================================================
|
|
Alain Reguera Delgado |
06ab0f |
----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
06ab0f |
Automation/Modules/
|
|
Alain Reguera Delgado |
06ab0f |
`-- $\{MODULE_NAME}
|
|
Alain Reguera Delgado |
06ab0f |
|-- Modules/ <-- module's sub-module files.
|
|
Alain Reguera Delgado |
06ab0f |
|-- Manuals/ <-- module's documentation files.
|
|
Alain Reguera Delgado |
06ab0f |
|-- Locales/ <-- module's localization files.
|
|
Alain Reguera Delgado |
06ab0f |
|-- Configs/ <-- module's configuration files.
|
|
Alain Reguera Delgado |
06ab0f |
`-- $\{MODULE_NAME}.sh <-- module's initialization file.
|
|
Alain Reguera Delgado |
06ab0f |
----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
06ab0f |
======================================================================
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
This structure, is common to all type of modules. You can nest
|
|
Alain Reguera Delgado |
06ab0f |
modules by creating directory structures like this, inside the
|
|
Alain Reguera Delgado |
06ab0f |
Modules/ directory of whatever module you want to extend its
|
|
Alain Reguera Delgado |
06ab0f |
functionality.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
The tcar_setModuleEnvironment function falls into the group of
|
|
Alain Reguera Delgado |
06ab0f |
global functions inside the centos-art.sh script. Its
|
|
Alain Reguera Delgado |
06ab0f |
implementation uses global array variables to store information
|
|
Alain Reguera Delgado |
06ab0f |
about the modules and local (non-array) variables to handle all
|
|
Alain Reguera Delgado |
06ab0f |
the information related to modules. Each time the
|
|
Alain Reguera Delgado |
06ab0f |
tcar_setModuleEnvironment function is called, it adds another
|
|
Alain Reguera Delgado |
06ab0f |
entry to MODULE_ array variables and uses local variables to set
|
|
Alain Reguera Delgado |
06ab0f |
the module's current information.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
In case you want to see debugging information for array variables
|
|
Alain Reguera Delgado |
06ab0f |
in tcar_setModuleEnvironment, you need to set the
|
|
Alain Reguera Delgado |
06ab0f |
TCAR_FLAG_DEBUGGING environment variable to "true". Generally, we
|
|
Alain Reguera Delgado |
06ab0f |
add the --debug option to modules, and set the variable there, so
|
|
Alain Reguera Delgado |
06ab0f |
you can control whether to see debug information or not from the
|
|
Alain Reguera Delgado |
06ab0f |
module's command-line.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
In the very beginning of tcar_setModuleEnvironment function we
|
|
Alain Reguera Delgado |
06ab0f |
were using just local variables and it worked fine for top-module
|
|
Alain Reguera Delgado |
06ab0f |
and sub-module loading, however when it was needed to load a
|
|
Alain Reguera Delgado |
06ab0f |
sibling module, centos-art.sh failed. The failure was produced
|
|
Alain Reguera Delgado |
06ab0f |
because a wrong variable assignment when tried to set the path of
|
|
Alain Reguera Delgado |
06ab0f |
the next module to load. There was not a clean way to "remember"
|
|
Alain Reguera Delgado |
06ab0f |
what was the base directory of the parent directory so we ended up
|
|
Alain Reguera Delgado |
06ab0f |
using the last loaded module base directory which made impossible
|
|
Alain Reguera Delgado |
06ab0f |
to load a sibling module. Using array variables to store
|
|
Alain Reguera Delgado |
06ab0f |
information about loaded modules fixes the issue of remembering
|
|
Alain Reguera Delgado |
06ab0f |
information from previous modules loaded.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
At this time the tcar_setModuleEnvironment function seems to work
|
|
Alain Reguera Delgado |
06ab0f |
as expected without any issue.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Options
|
|
Alain Reguera Delgado |
06ab0f |
-------
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
* -m ::
|
|
Alain Reguera Delgado |
06ab0f |
The name of the module you want to load. The argument of this
|
|
Alain Reguera Delgado |
06ab0f |
option should be module's initialization file (without extension).
|
|
Alain Reguera Delgado |
06ab0f |
* -t::
|
|
Alain Reguera Delgado |
06ab0f |
The type of module you want to load. The argument of this option
|
|
Alain Reguera Delgado |
06ab0f |
should be one of the following values (only):
|
|
Alain Reguera Delgado |
06ab0f |
* top-module::
|
|
Alain Reguera Delgado |
06ab0f |
is used when you want to load first-level modules, such as
|
|
Alain Reguera Delgado |
06ab0f |
render, locale and tuneup.
|
|
Alain Reguera Delgado |
06ab0f |
* sub-module::
|
|
Alain Reguera Delgado |
06ab0f |
is used when you want to load next-level modules. This is,
|
|
Alain Reguera Delgado |
06ab0f |
modules that are one inside another.
|
|
Alain Reguera Delgado |
06ab0f |
* sib-module::
|
|
Alain Reguera Delgado |
06ab0f |
is used when you want to load siblings modules. This is,
|
|
Alain Reguera Delgado |
06ab0f |
modules that are located at the same level.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Author
|
|
Alain Reguera Delgado |
06ab0f |
------
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
The *centos-art.sh* script has received contribution from the
|
|
Alain Reguera Delgado |
06ab0f |
following people:
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
* Alain Reguera Delgado <mailto:al@centos.org.cu[al@centos.org.cu]>, 2009-2013
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Copyright
|
|
Alain Reguera Delgado |
06ab0f |
---------
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
Copyright (C) 2009-2013 The CentOS Project
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
06ab0f |
it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
06ab0f |
the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
06ab0f |
your option) any later version.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
06ab0f |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
06ab0f |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
06ab0f |
General Public License for more details.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
06ab0f |
along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
06ab0f |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
06ab0f |
|
|
Alain Reguera Delgado |
06ab0f |
// vim: set syntax=asciidoc:
|