added file dependency check, switched back to english, smaller fix and improvements
This commit is contained in:
@@ -19,12 +19,12 @@ function die()
|
||||
trap - ERR
|
||||
|
||||
if [[ "$KEEPGOING" != "true" ]] || [[ "$2" == "--force" ]]; then
|
||||
prnt E "Sortie prématuré avec erreur (code #$errorcode)."
|
||||
prnt E "Premature exit with error (code #$errorcode)."
|
||||
# We remove KEEPGOING in case of --force so error() behave correctly
|
||||
export KEEPGOING=false
|
||||
exit $errorcode
|
||||
else
|
||||
prnt W "On continue malgrés l'erreur #$errorcode."
|
||||
prnt W "Continuing despite error #$errorcode."
|
||||
fi
|
||||
unset errorcode
|
||||
|
||||
@@ -38,7 +38,7 @@ export -f die
|
||||
# Function trigered on Ctrl+C pressed or external kill affecting us
|
||||
function terminate()
|
||||
{
|
||||
prnt E "$1 reçu, sortie immédiate."
|
||||
prnt E "$1 recieved, exiting at once."
|
||||
die 128 --force
|
||||
}
|
||||
trap "terminate 'Ctrl + C'" SIGINT
|
||||
@@ -54,13 +54,13 @@ function error()
|
||||
local code="${3:-1}"
|
||||
|
||||
# Print error header
|
||||
prnt E "${BIWhite}*** ${BIRed}Une erreur fatale est intervenue, le script va s'arrêter immédiatement !$DEFAULTCOL"
|
||||
prnt E "${BIWhite}*** ${BIRed}A fatal error occured, the script will stop now!$DEFAULTCOL"
|
||||
|
||||
if [[ -n "$message" ]]; then
|
||||
prnt E "Erreur ligne $parent_lineno, code d'erreur $code avec le message :"
|
||||
prnt E "Error line $parent_lineno, code $code with message:"
|
||||
echo -e "\t\t$message"
|
||||
else
|
||||
prnt E "Erreur ligne $(caller), avec le code d'erreur $code."
|
||||
prnt E "Error ligne $(caller), with error code $code."
|
||||
fi
|
||||
unset parent_lineno message code
|
||||
}
|
||||
@@ -85,7 +85,7 @@ function err_exit
|
||||
# Print a backtrace
|
||||
function backtrace
|
||||
{
|
||||
echo "======== Pile d'appel ========"
|
||||
echo "========= Call stack ========="
|
||||
typeset -i i=0
|
||||
|
||||
local func=
|
||||
@@ -134,7 +134,7 @@ check_root()
|
||||
return 0
|
||||
fi
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
prnt E "Ce script doit être démarré en tant que root. Arrêt."
|
||||
prnt E "That script must be run with root privileges."
|
||||
die 4 --force
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ export On_IWhite='\e[0;107m'
|
||||
# ------------------------------------------------------------------------------
|
||||
# Display status with color and timestamp
|
||||
# (-n on first parameter to stay on the same line)
|
||||
# ($1 accepted values: I=info, W=warning, E=error, m=des espaces (allignement)
|
||||
# ($1 accepted values: I=info, W=warning, E=error, m=spaces (alignment)
|
||||
# no header if anything else)
|
||||
prnt()
|
||||
{
|
||||
@@ -101,19 +101,19 @@ prnt()
|
||||
fi
|
||||
case $1 in
|
||||
"I")
|
||||
local heads="[ ${IGreen}info${DEFAULTFG} ]"
|
||||
shift ##
|
||||
local heads="[ ${IGreen}info${DEFAULTFG} ]"
|
||||
shift
|
||||
;;
|
||||
"W")
|
||||
local heads="[${IYellow}Attention${DEFAULTFG}]"
|
||||
local heads="[${IYellow}Warning${DEFAULTFG}]"
|
||||
shift
|
||||
;;
|
||||
"E")
|
||||
local heads="[ ${IRed}ERREUR${DEFAULTFG} ]"
|
||||
local heads="[ ${IRed}ERROR${DEFAULTFG} ]"
|
||||
shift
|
||||
;;
|
||||
"m")
|
||||
local heads=" "
|
||||
local heads=" "
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
@@ -134,7 +134,7 @@ dsleep()
|
||||
if [[ -n $2 ]]; then
|
||||
echo -n "$2"
|
||||
else
|
||||
echo -n "${i} "
|
||||
echo -n " ${i}"
|
||||
fi
|
||||
(( i=i-1 ))
|
||||
sleep 1
|
||||
|
||||
@@ -24,23 +24,24 @@ backupdist()
|
||||
local tmstmp=$(stdtime)
|
||||
if [[ -L ${file} ]]; then
|
||||
# With symbolik links we call again backupdist to treat target
|
||||
prnt I "Following the symbolic link $file to do a proper backup..."
|
||||
backupdist $(readlink -f ${file})
|
||||
elif [[ -f ${file} ]]; then
|
||||
prnt I "Création d'une sauvegarde de ${file} du $tmstmp..."
|
||||
prnt I "Creating a backup of ${file} on $tmstmp..."
|
||||
cp -av $file ${file}.dist.${tmstmp}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
prnt E "backupdist(): Échec de copie du fichier."
|
||||
prnt E "backupdist(): Failed copying file."
|
||||
die 12
|
||||
fi
|
||||
elif [[ -d ${file} ]]; then
|
||||
prnt I "Création d'une sauvegarde du répertoire ${file} du $tmstmp..."
|
||||
prnt I "Creation a backup of the directory ${file} on $tmstmp..."
|
||||
cp -av $file ${file}.dist.${tmstmp}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
prnt E "backupdist(): Échec de copie du répertoire."
|
||||
prnt E "backupdist(): Failed copyind directory recursively."
|
||||
die 12
|
||||
fi
|
||||
else
|
||||
prnt W "backupdist(): $file n'existe pas, rien à faire."
|
||||
prnt W "backupdist(): $file don't exists, nothing to do."
|
||||
fi
|
||||
unset tmstmp
|
||||
done
|
||||
@@ -103,14 +104,14 @@ installfile()
|
||||
unset file
|
||||
|
||||
if [[ -d $(dirname $i) ]]; then
|
||||
prnt I "Création du répertoire $(dirname $i) d'accueil..."
|
||||
prnt I "Creating required target directory $(dirname $i)..."
|
||||
mkdir -pv $(dirname $i)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
prnt E "installfile(): Can't create target dirrectory!"
|
||||
prnt E "installfile(): Can't create target directory!"
|
||||
die 12
|
||||
fi
|
||||
fi
|
||||
prnt I "Copie des fichiers ${filelist}..."
|
||||
prnt I "Copying files ${filelist} to target directory $(dirname $i)..."
|
||||
cp -av $filelist
|
||||
if [[ $? -ne 0 ]]; then
|
||||
prnt E "installfile(): Couldn't copy some required files!"
|
||||
@@ -135,7 +136,7 @@ appendfile()
|
||||
die 13
|
||||
fi
|
||||
|
||||
prnt I "Ajout de contenu au fichier $dstfile..."
|
||||
prnt I "Adding content to file $dstfile..."
|
||||
cat $srcfile >> $dstfile
|
||||
if [[ $? -ne 0 ]]; then
|
||||
prnt E "appendfile(): Couldn't append a file!"
|
||||
@@ -176,7 +177,7 @@ patchfile()
|
||||
local workfile=${dstfile}.work
|
||||
|
||||
if [[ ! -s $srcfile ]]; then
|
||||
prnt E "Le fichier source est vide, n'est pas un fichier ou n'existe pas"
|
||||
prnt E "The source file is empty, is not a file or don't exists!"
|
||||
die 10
|
||||
fi
|
||||
|
||||
@@ -210,4 +211,17 @@ patchfile()
|
||||
unset rights dstfile
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# check a file exists and return error if not
|
||||
file_exists()
|
||||
{
|
||||
prnt I "Checking $@ files existance..."
|
||||
for f in $@; do
|
||||
if [[ ! -f $(select_file $f) ]]; then
|
||||
prnt E "The $f file is missing, cannot continue."
|
||||
die 10
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# Upgrade package database
|
||||
pkgupdt()
|
||||
{
|
||||
prnt I "Mise à jour de la liste des paquets..."
|
||||
prnt I "Updating package list..."
|
||||
$PKG_MAN $COM_UPDATE
|
||||
}
|
||||
export -f pkgupdt
|
||||
@@ -23,21 +23,21 @@ export -f pkgupdt
|
||||
# Installation
|
||||
pkginst()
|
||||
{
|
||||
prnt I "Installation de paquets..."
|
||||
prnt I "Installing packages..."
|
||||
if [[ $# -lt 1 ]]; then
|
||||
prnt E "pkginst(): des paramètres sont requis."
|
||||
prnt E "pkginst(): some required parameters are missing."
|
||||
exit 11
|
||||
fi
|
||||
if [[ ! $INSTALL_MODE == dev ]]; then
|
||||
exec_preinst $@
|
||||
# exec_preinst $@
|
||||
$PKG_MAN $COM_INSTALL $@
|
||||
exec_postinst $@
|
||||
# exec_postinst
|
||||
else
|
||||
local pkg=
|
||||
for pkg in $@; do
|
||||
exec_preinst $pkg
|
||||
# exec_preinst $pkg
|
||||
$PKG_MAN $COM_INSTALL $pkg
|
||||
exec_postinst $pkg
|
||||
# exec_postinst
|
||||
done
|
||||
unset pkg
|
||||
fi
|
||||
@@ -49,10 +49,10 @@ export -f pkginst
|
||||
# Upgrade
|
||||
pkgupgd()
|
||||
{
|
||||
prnt I "Application de la mise à jours du système..."
|
||||
exec_preupgd
|
||||
prnt I "Applying system upgrade..."
|
||||
# exec_preupgd
|
||||
$PKG_MAN $COM_UPGRADE
|
||||
exec_postupgd
|
||||
# exec_postupgd
|
||||
}
|
||||
export -f pkgupgd
|
||||
|
||||
@@ -61,21 +61,21 @@ export -f pkgupgd
|
||||
# Uninstallation
|
||||
pkgrm()
|
||||
{
|
||||
prnt I "Désinstallation de paquets..."
|
||||
prnt I "Uninstalling packages..."
|
||||
if [[ $# -lt 1 ]]; then
|
||||
prnt E "pkgrem(): des paramètres sont requis."
|
||||
prnt E "pkgrem(): some required parameters are missing."
|
||||
exit 11
|
||||
fi
|
||||
if [[ ! $INSTALL_MODE == dev ]]; then
|
||||
exec_prerm $@
|
||||
# exec_prerm $@
|
||||
$PKG_MAN $COM_REMOVE $@
|
||||
exec_postrm
|
||||
# exec_postrm
|
||||
else
|
||||
local pkg=
|
||||
for pkg in $@; do
|
||||
exec_prerm $pkg
|
||||
# exec_prerm $pkg
|
||||
$PKG_MAN $COM_REMOVE $pkg
|
||||
exec_postrm
|
||||
# exec_postrm
|
||||
done
|
||||
uset pkg
|
||||
fi
|
||||
@@ -87,10 +87,10 @@ export -f pkgrm
|
||||
# Cleanup
|
||||
pkgautorm()
|
||||
{
|
||||
prnt I "Désinstallation de paquets superflus..."
|
||||
exec_preautorm
|
||||
prnt I "Uninstalling unneeded packages..."
|
||||
# exec_preautorm
|
||||
$PKG_MAN $COM_AUTOREM
|
||||
exec_postautorm
|
||||
# exec_postautorm
|
||||
}
|
||||
export -f pkgautorm
|
||||
|
||||
@@ -104,7 +104,7 @@ exec_preinst()
|
||||
unset $cmd
|
||||
for pkg in $pkglist; do
|
||||
if [[ $(function_exists preinst_$pkg) ]]; then
|
||||
prnt I "Exécution de la préinstallation de $pkg ..."
|
||||
prnt I "Running $pkg preinstallation script..."
|
||||
preinst_$pkg
|
||||
fi
|
||||
done
|
||||
@@ -123,7 +123,7 @@ exec_postinst()
|
||||
fi
|
||||
for pkg in $POSTINSTLIST; do
|
||||
if [[ $(function_exists postinst_$pkg) ]]; then
|
||||
prnt I "Exécution de la postinstallation de $pkg ..."
|
||||
prnt I "Running $pkg postinstallation script..."
|
||||
postinst_$pkg
|
||||
fi
|
||||
done
|
||||
@@ -141,7 +141,7 @@ exec_prerm()
|
||||
unset $cmd
|
||||
for pkg in $pkglist; do
|
||||
if [[ $(function_exists prerm_$pkg) ]]; then
|
||||
prnt I "Exécution du préretrait de $pkg ..."
|
||||
prnt I "Running $pkg preremove script..."
|
||||
prerm_$pkg
|
||||
fi
|
||||
done
|
||||
@@ -160,7 +160,7 @@ exec_postrm()
|
||||
fi
|
||||
for pkg in $POSTRMLIST; do
|
||||
if [[ $(function_exists postrm_$pkg) ]]; then
|
||||
prnt I "Exécution de la postretrait de $pkg ..."
|
||||
prnt I "Running $pkg postremove script..."
|
||||
postrm_$pkg
|
||||
fi
|
||||
done
|
||||
@@ -176,7 +176,7 @@ exec_preupgd()
|
||||
local pkglist=$($GET_UPGRADELIST)
|
||||
for pkg in $pkglist; do
|
||||
if [[ $(function_exists preupgd_$pkg) ]]; then
|
||||
prnt I "Exécution de la pré mise à jour de $pkg ..."
|
||||
prnt I "Running $pkg preupgrade script..."
|
||||
preupgd_$pkg
|
||||
fi
|
||||
done
|
||||
@@ -195,7 +195,7 @@ exec_postupgd()
|
||||
fi
|
||||
for pkg in $POSTUPGDLIST; do
|
||||
if [[ $(function_exists postupgd_$pkg) ]]; then
|
||||
prnt I "Exécution de la post mise à jour de $pkg ..."
|
||||
prnt I "Running $pkg postupgrade script..."
|
||||
postupgd_$pkg
|
||||
fi
|
||||
done
|
||||
@@ -211,7 +211,7 @@ exec_preautorm()
|
||||
local pkglist=$($GET_AUTOREMLIST)
|
||||
for pkg in $pkglist; do
|
||||
if [[ $(function_exists prerm_$pkg) ]]; then
|
||||
prnt I "Exécution du préretrait de $pkg ..."
|
||||
prnt I "Running $pkg preremove script..."
|
||||
prerm_$pkg
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
exec_serv()
|
||||
{
|
||||
if [[ $# -lt 2 ]]; then
|
||||
prnt E "exec_serv(): Erreur de syntaxe !"
|
||||
prnt E "exec_serv(): Syntax error!"
|
||||
exit 11
|
||||
fi
|
||||
|
||||
@@ -27,7 +27,7 @@ exec_serv()
|
||||
-e s/%com%/$command/)
|
||||
unset svcname command
|
||||
|
||||
prnt I "Lancement de la commande $command du services $svcname"
|
||||
prnt I "Launching command $command for the service $svcname"
|
||||
$lineexec
|
||||
return $?
|
||||
unset lineexec
|
||||
|
||||
@@ -16,7 +16,7 @@ read_commandline()
|
||||
{
|
||||
syntax_error()
|
||||
{
|
||||
prnt E "Erreur d'analyse de la ligne de commande, vérifiez vos paramètres."
|
||||
prnt E "Error while analysing command line, please check your parameters."
|
||||
die 1 --force
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ read_commandline()
|
||||
if [[ -s $STAGE_FILE ]]; then
|
||||
export RESUME=true
|
||||
else
|
||||
prnt E "Le fichier d'état n'existe pas ou est vide !"
|
||||
prnt E "Sans ce fichier, la reprise n'est pas possible."
|
||||
prnt E "The state file doesn't exists or is empty!"
|
||||
prnt E "Without it, resuming is impossible."
|
||||
die 1 --force
|
||||
fi
|
||||
;;
|
||||
@@ -90,8 +90,8 @@ read_commandline()
|
||||
export MANUAL_MODULE_LIST=$opt
|
||||
want_module=false
|
||||
else
|
||||
prnt E "Une liste de module à déjà été fournie !"
|
||||
prnt E "La ligne de commande ne tolère qu'un seul paramètre --module."
|
||||
prnt E "A module list have already been given!"
|
||||
prnt E "Commande line only tolerate one --module parameter."
|
||||
die 1 --force
|
||||
fi
|
||||
elif [[ $want_logfile == true ]]; then
|
||||
@@ -102,7 +102,7 @@ read_commandline()
|
||||
export NEW_LOGFILE=$opt
|
||||
want_logfile=false
|
||||
else
|
||||
prnt E "Il n'est pas possible de spécifier plusieurs fichiers de log."
|
||||
prnt E "It's impossible to specify several log files."
|
||||
die 1 --force
|
||||
fi
|
||||
elif [[ $want_conffile == true ]]; then
|
||||
@@ -119,11 +119,11 @@ read_commandline()
|
||||
export CHROOT_PATH=$opt
|
||||
want_chroot=false
|
||||
else
|
||||
prnt E "Un chemin pour chroot à déjà été fournis."
|
||||
prnt E "A chroot path have already been given."
|
||||
die 1 --force
|
||||
fi
|
||||
else
|
||||
prnt E "Paramètre \"$opt\" non géré."
|
||||
prnt E "Unknow parameter \"$opt\"."
|
||||
die 1 --force
|
||||
fi
|
||||
;;
|
||||
@@ -161,13 +161,13 @@ chroot_bootstrap()
|
||||
bootstrap_items="$bootstrap_items $STAGE_FILE"
|
||||
fi
|
||||
|
||||
prnt I "Préparation du changement de racine."
|
||||
prnt I "Preparing root change."
|
||||
cp -av $bootstrap_items $tmpdir
|
||||
|
||||
prnt I "Changement de racine et démarrage d'un fork d'init.sh..."
|
||||
prnt I "Changing root and starting a fork of init.sh..."
|
||||
chroot $CHROOT_PATH /bin/bash -c 'CHROOT_DONE=true; $tmpdir/init.sh $@'
|
||||
|
||||
prnt I "Retours au système hote et nettoyage."
|
||||
prnt I "Back to host system and clean up."
|
||||
rm -rf $tmpdir
|
||||
}
|
||||
|
||||
@@ -222,26 +222,26 @@ load_configuration()
|
||||
if [[ -n $CONFFILES ]]; then
|
||||
local f=
|
||||
for f in $CONFFILES; do
|
||||
prnt I "Chargement de $f spécifié manuellement."
|
||||
prnt I "Loading $f manuelly specified."
|
||||
if [[ -s $f ]]; then
|
||||
. $f
|
||||
else
|
||||
prnt E "Le fichier $f n'existe pas ou est vide."
|
||||
prnt E "The $f file doesn't exists or is empty."
|
||||
die 6 --force
|
||||
fi
|
||||
done
|
||||
unset f
|
||||
else
|
||||
prnt I "Chargement de la configuration..."
|
||||
prnt I "Loading configuration..."
|
||||
if [[ -e $MYPATH/conf/$HOSTNAME.conf.sh ]]; then
|
||||
prnt I "Une configuration spécifique sera utilisé."
|
||||
prnt I "A specific configuration will be used."
|
||||
. $MYPATH/conf/$HOSTNAME.conf.sh
|
||||
else
|
||||
if [[ -e $MYPATH/conf/init.conf.sh ]]; then
|
||||
prnt I "Une configuration générique sera utilisé."
|
||||
prnt I "A generic configuration will be used."
|
||||
. $MYPATH/conf/init.conf.sh
|
||||
else
|
||||
prnt E "Aucune configuration trouvée, impossible de continuer."
|
||||
prnt E "No configuration found, impossible to continue."
|
||||
die 6 --force
|
||||
fi
|
||||
fi
|
||||
@@ -257,46 +257,46 @@ process_commandline_and_vars()
|
||||
# Check unconsistant parameters
|
||||
if [[ $CHECK_ONLY == true ]]; then
|
||||
if [[ $JUMP == true ]]; then
|
||||
prnt E "Les options --check-only et --jump s'excluent mutuellement !"
|
||||
prnt E "The options --check-only and --jump are mutually exclusive!"
|
||||
die 1 --force
|
||||
fi
|
||||
if [[ $KEEPGOING == true ]]; then
|
||||
prnt E "Les options --keep-going et --check-only sont incompatible !"
|
||||
prnt E "The options --keep-going and --check-only are not compatible!"
|
||||
die 1 --force
|
||||
fi
|
||||
fi
|
||||
if [[ $RESUME == true ]]; then
|
||||
if [[ $CHECK_ONLY == true ]]; then
|
||||
prnt E "La reprise n'a pas de sens avec --check-only."
|
||||
prnt E "Resuming doesn't make sense with --check-only."
|
||||
die 1 --force
|
||||
fi
|
||||
if [[ $MANUAL_MODULE_LIST ]]; then
|
||||
prnt E "Le mode reprise ne fonctionne pas avec une liste de modules passé manuellement."
|
||||
prnt E "Recovery mode can't work with a manual module list."
|
||||
die 1 --force
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $CRON_MODE == true ]]; then
|
||||
if [[ $CHECK_ONLY == true || $JUMP == true ]]; then
|
||||
prnt E "Des paramètres sont incompatibles avec le mode cron."
|
||||
prnt E "Some parameters are incompatible with cron mode."
|
||||
die 16 --force
|
||||
fi
|
||||
fi
|
||||
|
||||
# Configure module list
|
||||
if [[ -n $MANUAL_MODULE_LIST ]]; then
|
||||
prnt W "Une liste de modules manuelle sera utilisé."
|
||||
prnt W "A manual module list will be used."
|
||||
export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g")
|
||||
fi
|
||||
|
||||
# Check for module list existance and basic syntax
|
||||
if [[ -n $MODULE_LIST ]]; then
|
||||
if [[ $(echo $MODULE_LIST | grep '-') ]]; then
|
||||
prnt E "Le tiret est interdit dans les noms de module."
|
||||
prnt E "Dash is forbidden in module name."
|
||||
die 5
|
||||
fi
|
||||
else
|
||||
prnt E "Aucun module à exécuter !"
|
||||
prnt E "No module to execute!"
|
||||
die 5
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user