added module documentation, improved main documentation

This commit is contained in:
fatalerrors
2021-07-05 12:06:59 +02:00
parent 7f7fa76391
commit 401f11b6b7
9 changed files with 146 additions and 31 deletions

114
README.md
View File

@@ -18,36 +18,109 @@ it would be a good idea to submit your module to init.sh source base.
- the init.sh script, which provide a simple framework and libraries to do - the init.sh script, which provide a simple framework and libraries to do
simple taks and embed system dependent functions to provide system independent simple taks and embed system dependent functions to provide system independent
function calls. function calls.
- modules that actually do the job on a system independant way through the use - modules that actually do the job, as possible on a system independant way
of the framework and consisting on very small and simple task. through the use of the framework and consisting on very small and simple tasks.
- multilevel configuration files, being simply Bash variables declaration. - multilevel configuration files, being simply Bash variables declaration.
Additionally some module might be ran regularly so it could be integrated in a Additionally some module might be ran regularly so it could be integrated in a
cron-like service. cron-like service.
### Command line
The **init.sh** script allows some command line parameters and some environement
variables to change it's behaviour.
The parameters are:
- **-m \<list\>, --module \<list\>**: Allows to manually give a module list and
overide the *MODULE_LIST* variable declaration. The list is a comma separated
module name. If that option is provided, the module list is mandatory.
- **-c, --check-only**: Do not launch any actions, only the checks are launched.
In that situation, no change should be done to the system.
- **-j, --jump**: Jump the checks and goes directly to system transformation.
That option should only be run after successfull checks (eg. after using the
**--checkonly** option).
- **-k, --keep-going**: The scripts will continue even if errors occurs. Thus
some unrecoverable errors might stop the script anyway if it not allowing it to
work. Please use with care as it might leads to unexpected results.
### Loading order and process
The first things the script do is loading its libraries contained in the "lib"
directory. Any file situated in that directory ending with the .sh extention
will be loaded in alphabetical order. For that reason, error management
functions are place in a file called aaa_error.sh, so it can be loaded first and
catch errors that could occurs while loading library files.
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
informations and don't require any superuser rights and exit at that point of
execution. Everything that follows will do and the script will exit with error
at that point if not superuser.
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 unconsistency or incompatible options.
Finally checking processes are launched in their declaration order (cf.
configuration file) and if not error and after a confirmation prompt, final
configuration process, those that actually makes changes, are launched.
Without the --keep-going option any error will imediatelly stop execution. Some
errors that could make the script impossible to execute will stop execution,
even if the --keep-going option is provided.
### Main configuration file ### Main configuration file
Writing in progress. The main configuration file can be two different file. Either it's completely
generic and will be named **init.conf.sh** in the "conf" directory, either it
will be named after the current hostname of the computer in that same "conf"
directory. Please remember that the actual name will be used until the end of
the execution of init.sh. If one of your module change the hostname, the new
name can only be took into account after a new execution of init.sh.
Most of the variable you can declare to configure your host depends on the
module you will use. Please refer to module header to see hat's available for
your use case.
It is heavily recommended to use includes technique to shorten your
configuration file and make a file for your organisation and an other one
for the Linux distribution you use. Remember that the declaration order matters,
so you can declare something on your organisation configuration file and
superseed it in your host configuration file. The only limit will be Bash
capabilities in terms of variable manipulation.
### Naming conventions ### Naming conventions
Because of internal mechanics the dash character is forbidden in module names. Thus Bash language also forbid that character in variable name. Because of internal mechanics the dash character is forbidden in module names.
Thus Bash language also forbid that character in variable name.
An other limit is, even if digits are allowed in module names and variable, they can't be used as a leading character or worse the full name being only made of digits. You can use as many digits you want in names but with at least a leading alphabetical (or underscore) character, whatever the case of that character will be. An other limit is, even if digits are allowed in module names and variable, they
can't be used as a leading character or worse the full name being only made of
digits. You can use as many digits you want in names but with at least a leading
alphabetical (or underscore) character, whatever the case of that character will
be.
You can use upper case and lower case as you wish, with underscore character, even as leading character. Any other special character than alphanumerical or underscore is completely forbidden. You can use upper case and lower case as you wish, with underscore character,
even as leading character. Any other special character than alphanumerical or
underscore is completely forbidden.
Any submitted module to the central repository will have module name in lower case with underscore to separate words and ease reading, and variable name upper case with the same underscore as word separator. Any submitted module to the central repository will have module name in lower
case with underscore to separate words and ease reading, and variable name upper
case with the same underscore as word separator.
### Basic module structure ### Basic module structure
Please note that modules are not supposed to contain any specific code for a Please note that modules are not supposed to contain any specific code for a
platform or a distribution even if nothing block you doing so. It is highly platform or a distribution even if nothing block you doing so. It is highly
recommended to use configurations files to introduce any platform dependent recommended to use configurations files to introduce any platform dependent
code. code. Additionally, it will be possible to create system dependent modules using
naming convention in the style module_name.debian.x86_64.sh (awaited for version
2 of init.sh).
In the following exemple @template@ have to be replaced with the name of your In the following exemple @template@ have to be replaced with the name of your
module with the filename @template@.sh. You can automatically create your new module with the following command: module with the filename @template@.sh. You can automatically create your new
module with the following command:
```shell ```shell
sed -e "s/@template@/module_name/g" -e "/^# .*/d" -e "s/^##/# /" template > \ sed -e "s/@template@/module_name/g" -e "/^# .*/d" -e "s/^##/# /" template > \
@@ -59,10 +132,10 @@ standard rules. Considering a numbering as x.y.z:
- x might be incremented in case of major change, rewriting or deferent approach - x might be incremented in case of major change, rewriting or deferent approach
on the way to have the job done on the way to have the job done
- y might be incremented in case simple finctionnality addition or basic - y might be incremented in case simple functionnality addition or basic
improvements improvements
- z might be incremented only when correcting problems and/or bugs (+n fix => +n - z might be incremented only when correcting problems and/or bugs (+n fix => +n
increment) to increment)
Unless only configuration files have been changed, any change in the code Unless only configuration files have been changed, any change in the code
implies any increment of a version number in the code **and** a git commit. implies any increment of a version number in the code **and** a git commit.
@@ -90,21 +163,4 @@ export -f @template@
export -f precheck_@template@ export -f precheck_@template@
``` ```
### Command line ## Contact and more information
The **init.sh** script allows some command line parameters and some environement
variables to change it's behaviour.
The parameters are:
- **-m \<list\>, --module=\<list\>**: Allows to manually give a module list and
overide the *MODULE_LIST* variable declaration. The list is a comma separated
module name. If that option is provided, the module list is mandatory.
- **-c, --check-only**: Do not launch any actions, only the checks are launched.
In that situation, no change should be done to the system.
- **-j, --jump**: Jump the checks and goes directly to system transformation.
That option should only be run after successfull checks (eg. after using the
**--checkonly** option).
- **-k, --keep-going**: The scripts will continue even if errors occurs. Thus
some unrecoverable errors might stop the script anyway if it not allowing it to
work.

View File

@@ -1,4 +1,13 @@
# Secondary drive configuration # Secondary drive configuration
# ------------------------------------------------------------------------------
# Variable :
# * CALCTYPE: filesystem to use (zfs, ext4, xfs)
# * CALCMOUNTPOINT: mount point of the target file system (FQPN)
# * CALCLEVEL: ZFS only, RAID level (mirror, raidz1, raidz2, raidz3),
# empty for striped volume. Any other level than stripe requires
# more than one disk.
# * CALCDRV: Target drives, preferably through ID.
# ------------------------------------------------------------------------------
export VER_conf_disks="0.0.7" export VER_conf_disks="0.0.7"

View File

@@ -1,4 +1,18 @@
# ------------------------------------------------------------------------------
# Locale # Locale
# ------------------------------------------------------------------------------
# Variable:
# * LOCALESET: List of locale that will be supported by system
# * SYSLOCALE: Default system wide locale
#
# Both case will be formated in that way (with exemple for French:
# fr_FR.UTF-8
# ^ ^ ^
# | | |
# ISO-631-1 language code | |
# ISO 3166-2 country subdivision |
# Character table (ISO or UTF)
# ------------------------------------------------------------------------------
export VER_conf_locale="0.0.3" export VER_conf_locale="0.0.3"

View File

@@ -1,4 +1,10 @@
# ------------------------------------------------------------------------------
# Mail systême # Mail systême
# ------------------------------------------------------------------------------
# Variable:
# * HOSTNAME: Name of the host
# * MAINDOM: Default main domain name
# ------------------------------------------------------------------------------
export VER_conf_mail="0.0.2" export VER_conf_mail="0.0.2"

View File

@@ -1,4 +1,9 @@
# ------------------------------------------------------------------------------
# NTP # NTP
# ------------------------------------------------------------------------------
# Variable:
# * NTPSERVERS: list of NTP servers
# ------------------------------------------------------------------------------
export VER_conf_ntp="0.0.5" export VER_conf_ntp="0.0.5"

View File

@@ -1,4 +1,9 @@
# Configuration des client et serveur SSH # ------------------------------------------------------------------------------
# Configure SSH client and server
# ------------------------------------------------------------------------------
# Variable:
# none
# ------------------------------------------------------------------------------
export VER_conf_ssh="0.0.1" export VER_conf_ssh="0.0.1"

View File

@@ -1,6 +1,11 @@
# ------------------------------------------------------------------------------
# Since Ubuntu install snapd version of Chromium and we don't want that # Since Ubuntu install snapd version of Chromium and we don't want that
# we need a special procedure to install Debian Buster version. # we need a special procedure to install Debian Buster version.
# Consequently that module is *Ubuntu centric. # Consequently that module is *Ubuntu centric.
# ------------------------------------------------------------------------------
# Variable:
# none
# ------------------------------------------------------------------------------
export VER_install_chromium="0.0.1" export VER_install_chromium="0.0.1"

View File

@@ -1,5 +1,13 @@
# ------------------------------------------------------------------------------
# Install desktop environment -- Ubuntu only # Install desktop environment -- Ubuntu only
# Debian version might ask for task-$FLAVOR # Debian version might ask for task-$FLAVOR
# ------------------------------------------------------------------------------
# Variable:
# * UBUNTU_FLAVOR: Kind of Ubuntu desktop installation (ubuntu for Gnome3,
# xubuntu for XFCE, kubuntu for KDE/Plasma, ubuntu-mate for Mate, leave
# empty for no desktop or manual)
# * X11_DRV: Used to install proprietary driver for X.org (eg: nvidia-drivers)
# ------------------------------------------------------------------------------
export VER_install_desktop="0.0.2" export VER_install_desktop="0.0.2"

View File

@@ -1,4 +1,11 @@
# Installation des paquets # ------------------------------------------------------------------------------
# Install or remove packages
# ------------------------------------------------------------------------------
# Variable:
# * PKGS_RMLIST: packages to remove
# * PKGS_BLACKLIST: package to mark as forbidden (will be removed if not)
# * PKGSEL: List of package to install
# ------------------------------------------------------------------------------
export VER_install_pkg="0.1.1" export VER_install_pkg="0.1.1"