dev.md: corrections and additions
This commit is contained in:
93
doc/dev.md
93
doc/dev.md
@@ -32,6 +32,20 @@
|
|||||||
- [6.1. Global dependencies](#61-global-dependencies)
|
- [6.1. Global dependencies](#61-global-dependencies)
|
||||||
- [6.2. Functions](#62-functions)
|
- [6.2. Functions](#62-functions)
|
||||||
- [6.2.1. exec_serv \<service\> \<command\>](#621-exec_serv-service-command)
|
- [6.2.1. exec_serv \<service\> \<command\>](#621-exec_serv-service-command)
|
||||||
|
- [6.2.2. svc_start \<service1\> [service2 ... serviceN]](#622-svc_start-service1-service2--servicen)
|
||||||
|
- [6.2.3. svc_reload \<service1\> [service2 ... serviceN]](#623-svc_reload-service1-service2--servicen)
|
||||||
|
- [6.2.2. svc_restart \<service1\> [service2 ... serviceN]](#622-svc_restart-service1-service2--servicen)
|
||||||
|
- [6.2.3. svc_stop \<service1\> [service2 ... serviceN]](#623-svc_stop-service1-service2--servicen)
|
||||||
|
- [6.3. Other functionnalities](#63-other-functionnalities)
|
||||||
|
- [7. The support.sh file](#7-the-supportsh-file)
|
||||||
|
- [7.1. Functions](#71-functions)
|
||||||
|
- [7.1.1. disp_help](#711-disp_help)
|
||||||
|
- [7.1.2. show_version](#712-show_version)
|
||||||
|
- [7.1.3. get_mod_name \<module_file\>](#713-get_mod_name-module_file)
|
||||||
|
- [8. The version.sh file](#8-the-versionsh-file)
|
||||||
|
- [8.1. Functions](#81-functions)
|
||||||
|
- [8.1.1. get_os_version](#811-get_os_version)
|
||||||
|
- [8.1.2. set_sys_var \<arch\> \<dist\> \<version\> \<codename\>](#812-set_sys_var-arch-dist-version-codename)
|
||||||
|
|
||||||
## 1. Getting started
|
## 1. Getting started
|
||||||
This is a developer's reference. It's not intended to be a manual, but a
|
This is a developer's reference. It's not intended to be a manual, but a
|
||||||
@@ -50,7 +64,7 @@ This function has no parameter.
|
|||||||
If the variable NO_ROOT_CHECK is set to true, the function always exit without
|
If the variable NO_ROOT_CHECK is set to true, the function always exit without
|
||||||
error and no check is done.
|
error and no check is done.
|
||||||
|
|
||||||
#### 2.1.2. die [--force] \<exitcode\>
|
#### 2.1.2. die \<exitcode\> [--force]
|
||||||
Trigger an error, print a back trace and exit the script, unless KEEPGOING
|
Trigger an error, print a back trace and exit the script, unless KEEPGOING
|
||||||
variable is set to true. In that situation, we just display a warning.
|
variable is set to true. In that situation, we just display a warning.
|
||||||
|
|
||||||
@@ -219,14 +233,14 @@ That function calls the package manager to remove no longer needed installed
|
|||||||
dependencies. Any package not manually installed is considered as a depndency.
|
dependencies. Any package not manually installed is considered as a depndency.
|
||||||
|
|
||||||
It depends on the *COM_AUTOREM* variable wich define the parameters to use to
|
It depends on the *COM_AUTOREM* variable wich define the parameters to use to
|
||||||
accomplish that function.
|
accomplish that functionenfin.
|
||||||
|
|
||||||
That function takes no parameters and any given parameters will be ignored.
|
That function takes no parameters and any given parameters will be ignored.
|
||||||
|
|
||||||
### 5.3. Other functionnalities
|
### 5.3. Other functionnalities
|
||||||
That file don't profide any other things that the previously listed functions.
|
That file don't profide any other things that the previously listed functions.
|
||||||
|
|
||||||
## 6. The services.sh files
|
## 6. The services.sh file
|
||||||
### 6.1. Global dependencies
|
### 6.1. Global dependencies
|
||||||
That script relies on the *INIT_COM* variable, defining the program to use to
|
That script relies on the *INIT_COM* variable, defining the program to use to
|
||||||
manipulate services. It is defined in configuration file automatically called
|
manipulate services. It is defined in configuration file automatically called
|
||||||
@@ -245,25 +259,25 @@ than two.
|
|||||||
|
|
||||||
The function returns the exit code of the service command.
|
The function returns the exit code of the service command.
|
||||||
|
|
||||||
#### 6.2.2. svc_start <service1> [service2 ... serviceN]
|
#### 6.2.2. svc_start \<service1\> [service2 ... serviceN]
|
||||||
Start the services given in parmeters. You can give as many services you want.
|
Start the services given in parmeters. You can give as many services you want.
|
||||||
|
|
||||||
That function relies on the previously documented exec_serv function.
|
That function relies on the previously documented exec_serv function.
|
||||||
|
|
||||||
#### 6.2.3. svc_reload <service1> [service2 ... serviceN]
|
#### 6.2.3. svc_reload \<service1\> [service2 ... serviceN]
|
||||||
Reload the configuration of the services given in parmeters. You can give as
|
Reload the configuration of the services given in parmeters. You can give as
|
||||||
many services you want. Be careful using this as some services don't have that
|
many services you want. Be careful using this as some services don't have that
|
||||||
capability.
|
capability.
|
||||||
|
|
||||||
That function relies on the previously documented exec_serv function.
|
That function relies on the previously documented exec_serv function.
|
||||||
|
|
||||||
#### 6.2.2. svc_restart <service1> [service2 ... serviceN]
|
#### 6.2.2. svc_restart \<service1\> [service2 ... serviceN]
|
||||||
Restart the services given in parmeters. It consist generally in a stop
|
Restart the services given in parmeters. It consist generally in a stop
|
||||||
immediately followed by a start. You can give as many services you want.
|
immediately followed by a start. You can give as many services you want.
|
||||||
|
|
||||||
That function relies on the previously documented exec_serv function.
|
That function relies on the previously documented exec_serv function.
|
||||||
|
|
||||||
#### 6.2.3. svc_stop <service1> [service2 ... serviceN]
|
#### 6.2.3. svc_stop \<service1\> [service2 ... serviceN]
|
||||||
Stop the services given in parmeters. You can give as many services you want.
|
Stop the services given in parmeters. You can give as many services you want.
|
||||||
|
|
||||||
That function relies on the previously documented exec_serv function.
|
That function relies on the previously documented exec_serv function.
|
||||||
@@ -271,3 +285,68 @@ That function relies on the previously documented exec_serv function.
|
|||||||
### 6.3. Other functionnalities
|
### 6.3. Other functionnalities
|
||||||
That file don't profide any other thing that the previously listed functions.
|
That file don't profide any other thing that the previously listed functions.
|
||||||
|
|
||||||
|
## 7. The support.sh file
|
||||||
|
### 7.1. Functions
|
||||||
|
#### 7.1.1. disp_help
|
||||||
|
That function display the help screen, usually called using the *--help* switch.
|
||||||
|
|
||||||
|
It's not taking any parameter and return nothing but help text.
|
||||||
|
|
||||||
|
#### 7.1.2. show_version
|
||||||
|
That function display the version of init.sh. It will also parse all the
|
||||||
|
available modules to display a table with their respecting versions.
|
||||||
|
|
||||||
|
If user is not root an additionnal warning will be displayed to warn the fact
|
||||||
|
the script requires root privileges to work properly.
|
||||||
|
|
||||||
|
As it's using colors to display results, it depends on color code declaration.
|
||||||
|
|
||||||
|
#### 7.1.3. get_mod_name \<module_file\>
|
||||||
|
That function return the name of the module file given in parameter. It takes
|
||||||
|
only one parameter: the module file name.
|
||||||
|
|
||||||
|
Result is sent to *stdout*.
|
||||||
|
|
||||||
|
## 8. The version.sh file
|
||||||
|
### 8.1. Functions
|
||||||
|
#### 8.1.1. get_os_version
|
||||||
|
That function takes no parameters and will return three values in order:
|
||||||
|
1. Distribution ID, in lowcase, usually equivalent to the distribution name.
|
||||||
|
2. Distribution version, if available, elsewhere kernel version with it's major.
|
||||||
|
3. Distribution codename (eg. buster for Debian 10) in lowercase if available.
|
||||||
|
|
||||||
|
The function mainly relies on the "*/etc/os-release*" new standard file. If your
|
||||||
|
distribution do not provide that file it is required you generate it yourself
|
||||||
|
before using init.sh. If you need help with the *os-release* file you can check
|
||||||
|
the [official documentation](https://www.freedesktop.org/software/systemd/man/os-release.html).
|
||||||
|
|
||||||
|
In "*/etc/os-release*" the variables *ID*, *VERSION_ID* and *VERSION_CODENAME*
|
||||||
|
will be the ones being analysed. Only the *ID* variable is mandatory.
|
||||||
|
|
||||||
|
#### 8.1.2. set_sys_var \<arch\> \<dist\> \<version\> \<codename\>
|
||||||
|
That function sets important variable that will store the system architecture.
|
||||||
|
It will allow the automatic loading of mandatory system dependent code and
|
||||||
|
variables. For debugging purpose it will be possible to call it manually.
|
||||||
|
|
||||||
|
Inside the init.sh initiallisation, it's called that way:
|
||||||
|
```shell
|
||||||
|
set_sys_vars $(uname -m) $(get_os_version)
|
||||||
|
```
|
||||||
|
|
||||||
|
All the four parameters have to be given in that order:
|
||||||
|
1. System architecture (eg. x86_64, i386, arm64...)
|
||||||
|
2. Distribution name (eg. debian, centos, ubuntu...)
|
||||||
|
3. Distribution version (or kernel version for rolling releases)
|
||||||
|
4. Distribution codename if available (eg. jessie, buster, bulleyes...)
|
||||||
|
|
||||||
|
If your distribution do not provide any codename, you have to give "null" as a
|
||||||
|
replacement parameter.
|
||||||
|
|
||||||
|
The following global variables will be set at the end of the execution:
|
||||||
|
- **SYS_ARCH** for the system architecture
|
||||||
|
- **SYS_DIST** for the distribution name
|
||||||
|
- **SYS_VER** for the distribution version
|
||||||
|
- **SYS_CODE** for the distribution codename
|
||||||
|
|
||||||
|
The *SYS_CODE* variable won't be set if your distribution provides no codename.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user