Merge branch 'master' of ssh://apo.geoffray-levasseur.org/share/services/git/legos
This commit is contained in:
76
doc/dev.md
76
doc/dev.md
@@ -13,12 +13,16 @@
|
||||
- [3.1.1. ```chroot_bootstrap```](#311-chroot_bootstrap)
|
||||
- [3.2. Other functionnalities](#32-other-functionnalities)
|
||||
- [4. The diskman.sh file](#4-the-diskmansh-file)
|
||||
- [4.1. Function](#41-function)
|
||||
- [4.2. Other functionnalities](#42-other-functionnalities)
|
||||
- [4.1. Global warning](#41-global-warning)
|
||||
- [4.2. Function](#42-function)
|
||||
- [4.2.1. ```blank_disk <bloc_device> [--full]```](#421-blank_disk-bloc_device---full)
|
||||
- [4.2.2. ```is_blank <bloc_device>```](#422-is_blank--bloc_device)
|
||||
- [4.3. Other functionnalities](#43-other-functionnalities)
|
||||
- [5. The command_line.sh file](#5-the-command_linesh-file)
|
||||
- [5.1. Functions](#51-functions)
|
||||
- [5.1.1. ```read_commandline```](#511-read_commandline)
|
||||
- [5.1.5. ```process_commandline_and_vars```](#515-process_commandline_and_vars)
|
||||
- [5.2. Other functionnalities](#52-other-functionnalities)
|
||||
- [6. The display.sh file](#6-the-displaysh-file)
|
||||
- [6.1. Functions](#61-functions)
|
||||
- [6.1.1. ```prnt [-n] [I|W|E|m] <message>```](#611-prnt--n-iwem-message)
|
||||
@@ -59,10 +63,11 @@
|
||||
- [10.1. Global dependencies](#101-global-dependencies)
|
||||
- [10.2. Functions](#102-functions)
|
||||
- [10.2.1. ```exec_serv <service> <command>```](#1021-exec_serv-service-command)
|
||||
- [10.2.2. ```svc_start <service1> [service2 ... serviceN]```](#1022-svc_start-service1-service2--servicen)
|
||||
- [10.2.3. ```svc_reload <service1> [service2 ... serviceN]```](#1023-svc_reload-service1-service2--servicen)
|
||||
- [10.2.2. ```svc_restart <service1> [service2 ... serviceN]```](#1022-svc_restart-service1-service2--servicen)
|
||||
- [10.2.3. ```svc_stop <service1> [service2 ... serviceN]```](#1023-svc_stop-service1-service2--servicen)
|
||||
- [10.2.2. ```svc_start <service1> [service2 [... serviceN]]```](#1022-svc_start-service1-service2--servicen)
|
||||
- [10.2.3. ```svc_reload <service1> [service2 [... serviceN]]```](#1023-svc_reload-service1-service2--servicen)
|
||||
- [10.2.2. ```svc_restart <service1> [service2 [... serviceN]]```](#1022-svc_restart-service1-service2--servicen)
|
||||
- [10.2.3. ```svc_stop <service1> [service2 [... serviceN]]```](#1023-svc_stop-service1-service2--servicen)
|
||||
- [10.3. Other functionnalities](#103-other-functionnalities)
|
||||
- [11. The support.sh file](#11-the-supportsh-file)
|
||||
- [11.1. Global behaviour](#111-global-behaviour)
|
||||
- [11.2. Functions](#112-functions)
|
||||
@@ -103,8 +108,8 @@ without error and no check is done.
|
||||
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.
|
||||
|
||||
If the parameter ```--force``` is given, we exit even if the KEEPGOING variable
|
||||
is set to true.
|
||||
If the parameter ```--force``` is given, we exit even if the ```KEEPGOING```
|
||||
variable is set to true.
|
||||
|
||||
#### 2.1.3. ```noerror [--noout] <command>```
|
||||
Allow the execution of a command bypassing the error management system. The
|
||||
@@ -121,8 +126,8 @@ command.
|
||||
The simple integration of aaa_error.sh file into a script, will change the
|
||||
entire script behavior regarding errors. The following Bash signals will be
|
||||
trapped:
|
||||
- **```ERR```**: The ERR signal is triggered every time Bash encounters an
|
||||
error or if a command return a non-zero value. The function called on that
|
||||
- **```ERR```**: The ```ERR``` signal is triggered every time Bash encounters
|
||||
an error or if a command return a non-zero value. The function called on that
|
||||
signal will stop execution of the script, displaying an error message with error
|
||||
code and a back trace to help identify the error origin. Because of this
|
||||
behavior, the function supersedes the internal ```errexit``` Bash configuration
|
||||
@@ -142,7 +147,7 @@ through the use of a *kill* command. The script will exit after cleanup.
|
||||
#### 3.1.1. ```chroot_bootstrap```
|
||||
That function is called if a chroot option have been given. It's in charge of
|
||||
performing the chroot, copying a full working directory structure of init.sh
|
||||
tree. After that copy a chroot command is runned launching that new copy of
|
||||
tree. After that copy, a chroot command is runned launching that new copy of
|
||||
init.sh.
|
||||
|
||||
If the child init.sh end with error, the stage file is gathered in parent
|
||||
@@ -163,21 +168,34 @@ your code when using those. By defaults the functions try to be as conservative
|
||||
as they can, triguering errors on the smallest doubt.
|
||||
|
||||
### 4.2. Function
|
||||
#### 4.2.1. ```blank_disk <bloc_device>```
|
||||
#### 4.2.1. ```blank_disk <bloc_device> [--full]```
|
||||
Blank a block device using two different method to be sure it's all clear. First
|
||||
we use the *wipefs* method specialized in reseting all possible flags on the
|
||||
drive and it's partitions. It will also blank the partition table. A second pass
|
||||
will fill the first 512 MB with zeroes to also blank MBR and other parts of the
|
||||
drive wipefs would have ignored.
|
||||
|
||||
If the parameter ```--full``` is provided as second parameter, the entire disk
|
||||
will be filled with zeroes. Please consider that such operation might take a
|
||||
very long time (can be several hours).
|
||||
|
||||
That function only take parameter which must be a bloc device.
|
||||
|
||||
#### 4.2.2. ```is_blank <bloc_device>```
|
||||
That function will try to detect if a drive is blank of not. It will return 0 if
|
||||
the drive is blank, and return 1 otherwise. Please consider that special drive
|
||||
configuration could be detected as blank while it's not. Only one parameter will
|
||||
be accepted, a bloc device. The bloc device you provide is suposed to be a whole
|
||||
drive, not a partition.
|
||||
the drive is blank, and return 1 otherwise. If the function return 2, either the
|
||||
provided parameter is not a block device or that block device do not exists.
|
||||
|
||||
Please consider that special drive configuration could be detected as blank
|
||||
while it's not. Only one parameter will be accepted, a bloc device.
|
||||
|
||||
The function will give different information depending on the bloc device you
|
||||
test:
|
||||
- on a whole disk drive it while return 0 if the drive is blank, meaning no MBR
|
||||
and no partition table (either GTP or DOS);
|
||||
- on a partition it will tell if it's formated or not. Beware that an erased
|
||||
then recreated partion will continue to have old partition data available and
|
||||
will be shown as non blank.
|
||||
|
||||
#### 4.2.3. ```mkparts <disk> [dos|gpt] [size_part1 [... size_partN]]```
|
||||
This function create partitions on the disk given as the first parameter. The
|
||||
@@ -200,7 +218,7 @@ Be warned that a size (whatever the unit is) can result in slightly different
|
||||
space depending on the drive model and cylinder size.
|
||||
|
||||
### 4.3. Other functionnalities
|
||||
That file don't profide any other things that the previously listed functions.
|
||||
That file don't provide any other things that the previously listed functions.
|
||||
|
||||
## 5. The command_line.sh file
|
||||
### 5.1. Functions
|
||||
@@ -242,7 +260,7 @@ character.
|
||||
That function will also triger an error if the definitive module list is empty.
|
||||
|
||||
### 5.2. Other functionnalities
|
||||
That file don't profide any other things that the previously listed functions.
|
||||
That file don't provide any other things that the previously listed functions.
|
||||
|
||||
## 6. The display.sh file
|
||||
### 6.1. Functions
|
||||
@@ -427,7 +445,7 @@ function is logicaly massively used during check phase to verify all source
|
||||
directories are in place.
|
||||
|
||||
### 7.3. Other functionnalities
|
||||
That file don't profide any other things that the previously listed functions.
|
||||
That file don't provide any other things that the previously listed functions.
|
||||
|
||||
## 8. The loaders.sh file
|
||||
### 8.1. Functions
|
||||
@@ -456,7 +474,7 @@ If no configuration file can be found the function will trigger an error and
|
||||
exit the script.
|
||||
|
||||
### 8.2. Other functionnalities
|
||||
That file don't profide any other things that the previously listed functions.
|
||||
That file don't provide any other things that the previously listed functions.
|
||||
|
||||
## 9. The pkgman.sh file
|
||||
### 9.1. Global dependencies
|
||||
@@ -591,36 +609,36 @@ than two.
|
||||
|
||||
The function returns the exit code of the service command.
|
||||
|
||||
#### 10.2.2. ```svc_start <service1> [service2 ... serviceN]```
|
||||
#### 10.2.2. ```svc_start <service1> [service2 [... serviceN]]```
|
||||
Start the services given in parmeters. You can give as many services you want.
|
||||
|
||||
That function relies on the previously documented exec_serv function.
|
||||
|
||||
#### 10.2.3. ```svc_reload <service1> [service2 ... serviceN]```
|
||||
#### 10.2.3. ```svc_reload <service1> [service2 [... serviceN]]```
|
||||
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
|
||||
capability.
|
||||
|
||||
That function relies on the previously documented exec_serv function.
|
||||
|
||||
#### 10.2.2. ```svc_restart <service1> [service2 ... serviceN]```
|
||||
#### 10.2.2. ```svc_restart <service1> [service2 [... serviceN]]```
|
||||
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.
|
||||
|
||||
That function relies on the previously documented exec_serv function.
|
||||
|
||||
#### 10.2.3. ```svc_stop <service1> [service2 ... serviceN]```
|
||||
#### 10.2.3. ```svc_stop <service1> [service2 [... serviceN]]```
|
||||
Stop the services given in parmeters. You can give as many services you want.
|
||||
|
||||
That function relies on the previously documented exec_serv function.
|
||||
|
||||
### 10.3. Other functionnalities
|
||||
That file don't profide any other thing that the previously listed functions.
|
||||
That file don't provide any other thing that the previously listed functions.
|
||||
|
||||
## 11. The support.sh file
|
||||
### 11.1. Global behaviour
|
||||
That file is designed to just display information. It only contains code that
|
||||
don't requires any special writes, and do nothing to the system. The idea is to
|
||||
don't requires any special rights, and do nothing to the system. The idea is to
|
||||
have the minimal sets of dependencies. As it's sometimes using colors to display
|
||||
results, it depends only on color code declaration in the ```display.sh``` file.
|
||||
|
||||
@@ -638,7 +656,7 @@ If user is not root an additionnal warning will be displayed to warn the fact
|
||||
the script requires root privileges to work properly.
|
||||
|
||||
### 11.3. Other functionnalities
|
||||
That file don't profide any other thing that the previously listed functions.
|
||||
That file don't provide any other thing that the previously listed functions.
|
||||
|
||||
## 12. The utils.sh file
|
||||
### 12.1. Functions
|
||||
@@ -670,7 +688,7 @@ That function takes no parameters and only change ```http_proxy``` and
|
||||
```https_proxy``` standard POSIX variables. No usefull result will be returned.
|
||||
|
||||
### 12.2. Other functionnalities
|
||||
That file don't profide any other thing that the previously listed functions.
|
||||
That file don't provide any other thing that the previously listed functions.
|
||||
|
||||
## 13. The version.sh file
|
||||
### 13.1. Functions
|
||||
@@ -716,7 +734,7 @@ The following global variables will be set at the end of the execution:
|
||||
The ```SYS_CODE``` variable won't be set if your distribution provides no codename.
|
||||
|
||||
### 13.2. Other functionnalities
|
||||
That file don't profide any other thing that the previously listed functions.
|
||||
That file don't provide any other thing that the previously listed functions.
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
@@ -17,7 +17,14 @@ blank_disk()
|
||||
prnt I "Wipping $1 drive signature (a backup is made in /root)..."
|
||||
wipefs --force --all --backup /dev/$1
|
||||
prnt I "Filling beginning of $1 drive with zeroes..."
|
||||
if [[ $2 == "--full" ]]; then
|
||||
# If full we display progress as it might take a very long time
|
||||
# Need true to avoid error as the last byte will generate a disk
|
||||
# full error
|
||||
dd if="/dev/zero" of="$1" bs="512" status=progress || true
|
||||
else
|
||||
dd if="/dev/zero" of="$1" bs="512" count="1024"
|
||||
fi
|
||||
|
||||
# Update kernel partition scheme
|
||||
partprobe
|
||||
@@ -29,9 +36,13 @@ blank_disk()
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Check if $1 is a block device and if it's blank
|
||||
# Check if $1 is a blank block device. Return values:
|
||||
# * 0 if empty block device
|
||||
# * 1 if not empty block device
|
||||
# * 2 if not block device or if it don't exists
|
||||
is_blank()
|
||||
{
|
||||
if [[ -b /dev/$1 ]]; then
|
||||
# That technique is fast but might not be relayable enough if we are on
|
||||
# exotic data structure or filesystem...
|
||||
local devstat=$(file /dev/$1 | sed "s@/dev/$1: @@")
|
||||
@@ -40,6 +51,9 @@ is_blank()
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
return 2
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user