reworked on error code, create associated doc, module list checks
This commit is contained in:
19
README.md
19
README.md
@@ -162,5 +162,24 @@ precheck_@template@()
|
||||
export -f @template@
|
||||
export -f precheck_@template@
|
||||
```
|
||||
## Error code table
|
||||
|
||||
The following table is giving a list of error code with explanation:
|
||||
|
||||
| Code | Meaning |
|
||||
|:----------|:----------------------------------------|
|
||||
| 0 | No error |
|
||||
| 1 | Command line syntax error |
|
||||
| 2 | Unable to find configuration |
|
||||
| 3 | Missing library file or function |
|
||||
| 4 | No root rights |
|
||||
| 5 | Malformed module list |
|
||||
| 10 | Function call error |
|
||||
| 11 | Bad function call |
|
||||
| 12 | Error copying files |
|
||||
| 13 | Bad target filesystem |
|
||||
| 50..100 | Error in module execution |
|
||||
| 128 | Abortion due to external cause |
|
||||
| 150..200 | Error in module checks |
|
||||
|
||||
## Contact and more information
|
||||
|
||||
15
init.sh
15
init.sh
@@ -45,7 +45,7 @@ function_exists() {
|
||||
function_exists prnt || (
|
||||
echo "*** ERREUR FATALE !"
|
||||
echo "*** Il manque des fonctions vitales venant des bibliothèques."
|
||||
exit 2
|
||||
exit 3
|
||||
)
|
||||
|
||||
# ======================
|
||||
@@ -114,7 +114,7 @@ done
|
||||
# (--help and --version are allowed as unprivileged user)
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
prnt E "Ce script doit être démarré en tant que root. Arrêt."
|
||||
die 1 --force
|
||||
die 4 --force
|
||||
fi
|
||||
|
||||
# Logfile variable treatment
|
||||
@@ -178,6 +178,17 @@ if [[ $MANUAL_MODULE_LIST ]]; then
|
||||
export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g")
|
||||
fi
|
||||
|
||||
# Check for module list existance en basic syntax
|
||||
if [[ -n $MODULE_LIST ]]; then
|
||||
if [[ $(echo $MODULE_LIST | grep '-') ]]; then
|
||||
prnt E "Le tiret est interdit dans les noms de module."
|
||||
die 5
|
||||
fi
|
||||
else
|
||||
prnt E "Aucun module à exécuter !"
|
||||
die 5
|
||||
fi
|
||||
|
||||
# Run prechecks
|
||||
[[ JUMP != true ]] && for mod in $MODULE_LIST; do
|
||||
. modules/$mod.sh
|
||||
|
||||
@@ -12,7 +12,7 @@ backupdist()
|
||||
{
|
||||
[[ $# -lt 1 ]] &&
|
||||
prnt E "backupdist(): Au moins un argument requis." &&
|
||||
exit 129
|
||||
exit 11
|
||||
|
||||
for file in $@; do
|
||||
if [[ -e ${file} ]]; then
|
||||
@@ -32,11 +32,11 @@ installfile()
|
||||
|
||||
[[ $# -lt 2 ]] && (
|
||||
prnt E "installfile(): Au moins deux arguments requis."
|
||||
exit 129
|
||||
die 11
|
||||
)
|
||||
[[ $(echo $@ | grep "\*\|\?") ]] && (
|
||||
prnt E "installfile(): Les wildcards sont interdits."
|
||||
exit 10
|
||||
die 10
|
||||
)
|
||||
|
||||
for arg in $@; do
|
||||
@@ -52,11 +52,14 @@ installfile()
|
||||
for i in $filelist; do :; done
|
||||
if [[ ! $i==/* ]]; then
|
||||
prnt E "installfile(): Target must be on the root filesystem."
|
||||
exit 3
|
||||
die 13
|
||||
fi
|
||||
prnt I "Création du répertoire $(dirname $i) si nécessaire..."
|
||||
mkdir -pv $(dirname $i)
|
||||
prnt I "Copie des fichiers ${filelist}..."
|
||||
cp -av $filelist
|
||||
cp -av $filelist || (
|
||||
prnt E "installfile(): Couldn't copy some required files..." &&
|
||||
die 12
|
||||
)
|
||||
}
|
||||
export -f installfile
|
||||
|
||||
@@ -5,7 +5,7 @@ exec_serv()
|
||||
{
|
||||
[[ $# -lt 2 ]] && (
|
||||
prnt E "exec_serv(): Erreur de syntaxe !"
|
||||
exit 130
|
||||
exit 11
|
||||
)
|
||||
|
||||
local svcname=$1 command=$2
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# * CALCDRV: Target drives, preferably through ID.
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_disks="0.0.7"
|
||||
export VER_conf_disks="0.0.8"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# ZFS case
|
||||
@@ -26,7 +26,7 @@ conf_zfs()
|
||||
# Load ZFS module to check it works
|
||||
modprobe zfs || (
|
||||
prnt E "Échec de chargement du module noyau, abandon."
|
||||
die 2
|
||||
die 50
|
||||
)
|
||||
sleep 1
|
||||
|
||||
@@ -57,7 +57,7 @@ conf_zfs()
|
||||
fi
|
||||
else
|
||||
prnt E "Erreur de création du pool zcalc ($CALCLEVEL) avec les disques $CALCDRV"
|
||||
die 3
|
||||
die 51
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ precheck_conf_disks()
|
||||
{
|
||||
if [[ ! $(type -t conf_$CALCTYPE) == "function" ]]; then
|
||||
prnt E "Format de disque inconnu ($CALCTYPE) !"
|
||||
die 5
|
||||
die 150
|
||||
fi
|
||||
|
||||
prnt I "Vérification des lecteurs pour disque de calcul."
|
||||
@@ -130,14 +130,14 @@ precheck_conf_disks()
|
||||
fi
|
||||
else
|
||||
prnt E "Le disque $drv n'existe pas. Abandon."
|
||||
die 5
|
||||
die 150
|
||||
fi
|
||||
(( drvcount+=1 ))
|
||||
done
|
||||
|
||||
if [[ ! $CALCTYPE=="zfs" && drvcount -gt 1 ]]; then
|
||||
prnt E "Plusieurs diques impossibles avec Ext4 ou XFS !"
|
||||
die 5
|
||||
die 150
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# * NTPSERVERS: list of NTP servers
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_ntp="0.0.5"
|
||||
export VER_conf_ntp="0.0.6"
|
||||
|
||||
conf_ntp()
|
||||
{
|
||||
@@ -40,7 +40,7 @@ precheck_conf_ntp()
|
||||
{
|
||||
if [[ -z $NTPSERVERS ]]; then
|
||||
prnt E "Pas de serveur NTP configuré !"
|
||||
die 5
|
||||
die 151
|
||||
else
|
||||
prnt m "Les serveurs ntp utilisés seront : $NTPSERVERS"
|
||||
fi
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# * PROXYAPTPORT: Working port for APT proxy
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_upgrade_dist="0.0.6"
|
||||
export VER_upgrade_dist="0.0.7"
|
||||
|
||||
upgrade_dist()
|
||||
{
|
||||
@@ -18,7 +18,7 @@ upgrade_dist()
|
||||
if [[ ! -d $(basedir $proxyfile) ]]; then
|
||||
mkdir -pv /etc/apt/apt.conf.d || (
|
||||
prnt E "Impossiblle de créer le répertoire d'accueil pour la configuration d'APT."
|
||||
exit 10
|
||||
die 60
|
||||
)
|
||||
fi
|
||||
backupdist $proxyfile
|
||||
@@ -42,11 +42,11 @@ precheck_upgrade_dist()
|
||||
wget -q --tries=10 --timeout=20 --spider http://www.cnrs.fr
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
prnt E "Réseau non fonctionnel ! Abandon."
|
||||
die 5
|
||||
die 160
|
||||
fi
|
||||
if [[ -n $PROXYAPT && -z $PROXYAPTPORT ]]; then
|
||||
prnt E "Un serveur proxy a été spécifié mais pas son port d'usage."
|
||||
die 5
|
||||
die 160
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user