README.md: improved doc, added autoload details

This commit is contained in:
fatalerrors
2021-10-05 11:59:35 +02:00
parent 5a36c277ba
commit 976b0d4e19

View File

@@ -5,16 +5,18 @@ its requirements turn it naturally to Linux systems. It has long been tested
using Debian GNU/Linux, Devuan and different flavors of Ubuntu.
## Table of content
* [1. Getting started](#1-getting-started)
* [2. Design](#2-design)
+ [2.1. Command line](#21-command-line)
+ [2.2. Loading order and process](#22-loading-order-and-process)
+ [2.3. Main configuration file](#23-main-configuration-file)
+ [2.4. Naming conventions](#24-naming-conventions)
+ [2.5. Basic module structure](#25-basic-module-structure)
* [3. Error code table](#3-error-code-table)
* [4. Contact and more information](#4-contact-and-more-information)
- [init.sh](#initsh)
- [1. Getting started](#1-getting-started)
- [2. Design](#2-design)
- [2.1. Command line](#21-command-line)
- [2.2. Loading order and process](#22-loading-order-and-process)
- [2.3. Configuration files](#23-configuration-files)
- [2.3.1. Main configuration file](#231-main-configuration-file)
- [2.3.2. Automatically loaded configuration files](#232-automatically-loaded-configuration-files)
- [2.4. Naming conventions](#24-naming-conventions)
- [2.5. Basic module structure](#25-basic-module-structure)
- [3. Error code table](#3-error-code-table)
- [4. Contact and more information](#4-contact-and-more-information)
## 1. Getting started
You should consider reading that document entirely before use. If you need
@@ -87,14 +89,18 @@ opposite the zzz_main_fct.sh file have to be loaded last, because it's widely
using previously declared libraries.
After that, a basic command line parameter treatment is done. That allows the
use of --version and --help options in user space. Those options just display
use of *--version* and *--help* options in user space. Those options display
information and don't require any superuser rights and exit at that point of
execution. Everything after that will require administrator rights and the
script will exit with error at that point if not superuser.
script will exit with error at that point if not superuser, unless the
*--no-root-check* option have been given.
Next will be the log file creation and the loading of configuration files. At
this point a deeper analysis of command line option will be done, triggering
errors in case of inconsistency or incompatible options.
Next will be the log file creation and the loading of configuration files.
Configuration files exists in two distinct categories. First system dependant
configuration will be loaded automatically depending on your platform, then
your own configuration. At this point a deeper analysis of command line option
will be done, triggering errors in case of inconsistency or incompatible
options.
Finally, checking processes are launched in their declaration order (cf.
configuration file). If no error occurs and after a confirmation prompt, final
@@ -104,7 +110,8 @@ Without the *--keep-going* option, any error will immediately stop execution.
Some errors that could make the script impossible to execute will stop
execution, even if the *--keep-going* option is provided.
### 2.3. Main configuration file
### 2.3. Configuration files
#### 2.3.1. Main configuration file
The main configuration file can be two different files. Either it's completely
generic and will be named **init.conf.sh** in the "conf" directory, either it
@@ -128,6 +135,32 @@ so you can declare something on your organization configuration file and
supersede it in your host configuration file. The only limit will be Bash
capabilities in terms of variable manipulation.
#### 2.3.2. Automatically loaded configuration files
Those file are basically the system dependent part that assure compatibility
with different Linux distributions. Some of those files are shipped with
init.sh but you can add what you want to improve possibilities or to add support
for a new distribution. init.sh understand the following possibilities in terms
of OS detection:
| Name | Variable | |
|:------------|:---------|:----------------------------------------------------|
| **arch** | SYS_ARCH | This is the system architecture, like x86_64, i386, arm64, etc. |
| **dist** | SYS_DIST | The name of the Linux distribution as reported by */etc/os-release*. |
| **version** | SYS_VER | Version of the distribution. If you run a rolling release and no version is provided by your */etc/os-release* file, the main version of the Linux kernel will be used (e.g. 5.4 for any version of 5.4. kernel branch). |
| **codename**| SYS_CODE | If your distribution profide a version codename, it will be set with it. |
The configuration files are loaded if exists in the following order:
1) arch.conf.sh
2) distro.conf.sh
3) distro-arch.conf.sh
4) distro-version.conf.sh
5) distro-codename.conf.sh (if *$SYS_CODE* defined)
6) distro-version-arch.conf.sh
7) distro-codename-arch.conf.sh (if *$SYS_CODE* defined)
The loading of those files, if one exists, cannot be avoided. They all must be
located in the *conf/auto* directory of the init.sh tree.
### 2.4. Naming conventions
Because of internal mechanics, the dash character is forbidden in module names.