added file dependency check, switched back to english, smaller fix and improvements
This commit is contained in:
60
init.sh
60
init.sh
@@ -55,8 +55,8 @@ unset lib
|
||||
# =============================
|
||||
|
||||
function_exists prnt || (
|
||||
echo "*** ERREUR FATALE !"
|
||||
echo "*** Il manque des fonctions vitales venant des bibliothèques."
|
||||
echo "*** FATAL ERROR!"
|
||||
echo "*** Some vital functions comming from libraries are missing."
|
||||
exit 3
|
||||
)
|
||||
|
||||
@@ -89,7 +89,7 @@ else
|
||||
export LOGFILE=${LOGFILE:-"$MYPATH/log/init-$(uname -n)-$(stdtime).log"}
|
||||
fi
|
||||
|
||||
prnt I "Création du répertoire d'accueil du fichier log..."
|
||||
prnt I "Creating log files welcoming directory..."
|
||||
if [[ ! -d $(dirname $LOGFILE) ]]; then
|
||||
mkdir -pv $(dirname $LOGFILE)
|
||||
fi
|
||||
@@ -99,12 +99,12 @@ exec 3>&1 4>&2
|
||||
trap 'exec 2>&4 1>&3' 0 1 2 3
|
||||
exec > >(tee -a $LOGFILE)
|
||||
exec 2> >(tee -a $LOGFILE >&2)
|
||||
prnt I "Démarrage d'init version $VERSION."
|
||||
prnt I "Le fichier de log est $LOGFILE."
|
||||
prnt I "Starting init.sh version $VERSION."
|
||||
prnt I "The log file is $LOGFILE."
|
||||
if [[ -n $SYS_CODE ]]; then
|
||||
prnt I "Lancé sur $SYS_DIST version $SYS_VER ($SYS_CODE) architecture $SYS_ARCH"
|
||||
prnt I "Launch on $SYS_DIST version $SYS_VER ($SYS_CODE) on $SYS_ARCH architecture"
|
||||
else
|
||||
prnt I "Lancé sur $SYS_DIST version $SYS_VER architecture $SYS_ARCH"
|
||||
prnt I "Launch on $SYS_DIST version $SYS_VER on $SYS_ARCH architecture"
|
||||
fi
|
||||
|
||||
# -- Cannot be a function ends here
|
||||
@@ -112,7 +112,7 @@ fi
|
||||
|
||||
if [[ -n $CHROOT_PATH && -z $CHROOT_DONE ]]; then
|
||||
chroot_bootstrap $@
|
||||
prnt I "Fin normale d'execution chrootée !"
|
||||
prnt I "Normal end of chrooted execution!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -121,7 +121,7 @@ load_autoconf
|
||||
load_configuration
|
||||
|
||||
# Load pre and post actions for package manager
|
||||
for prepost in $MYPATH/prepost/*.sh; do
|
||||
for prepost in $MYPATH/prepost.d/*.sh; do
|
||||
. $prepost
|
||||
done
|
||||
unset $prepost
|
||||
@@ -142,9 +142,9 @@ done
|
||||
unset mod
|
||||
|
||||
if [[ $RUN_SHELL == true ]]; then
|
||||
prnt I "Lancement d'un shell intéractif..."
|
||||
prnt I "Launching an interactive shell..."
|
||||
bash --rcfile $MYPATH/bash.rc -i
|
||||
prnt I "Sortie du script après exécution du shell."
|
||||
prnt I "Script execution terminated after interactive shell execution."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -162,14 +162,20 @@ if [[ $CRON_MODE == true ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Install basic dependencies if needed
|
||||
if ! command -v wget &> /dev/null; then
|
||||
prnt I "Installing wget as a requirement for init.sh to work..."
|
||||
pkginst wget
|
||||
fi
|
||||
|
||||
# Run prechecks
|
||||
if [[ JUMP != true ]]; then
|
||||
tmpfile=$(mktemp /tmp/init-XXXXXX)
|
||||
if [[ -n $MANUAL_MODULE_LIST ]]; then
|
||||
prnt W "La vérification des dépendences est désactivé avec une liste manuelle de module."
|
||||
prnt W "Dependency checks are deactivated with a manual module list."
|
||||
fi
|
||||
if [[ $NO_DEPS == true ]]; then
|
||||
prnt W "La vérification des dépendences à été désactivée manuellement."
|
||||
prnt W "Dependency checks have been deactivated manually."
|
||||
fi
|
||||
if [[ $RESUME == true ]]; then
|
||||
cat $STAGE_FILE >> $tmpfile
|
||||
@@ -177,16 +183,16 @@ if [[ JUMP != true ]]; then
|
||||
for mod in $MODULE_LIST; do
|
||||
version=VER_$mod
|
||||
if [[ $RESUME == true ]] && [[ $(grep $mod $STAGE_FILE) ]]; then
|
||||
prnt I "Vérification précédemment exécuté pour $mod version ${!version}."
|
||||
prnt I "Checks previously executed for $mod version ${!version}."
|
||||
continue
|
||||
fi
|
||||
prnt I "Vérification initiale pour $mod version ${!version}..."
|
||||
prnt I "Running initial checks for $mod version ${!version}..."
|
||||
if [[ -z $MANUAL_MODULE_LIST && $NO_DEPS != true ]]; then
|
||||
deps=DEP_$mod
|
||||
for dep in ${!deps}; do
|
||||
if [[ ! $(grep $dep $tmpfile) ]]; then
|
||||
prnt E "Le module $mod a des dépendances non satisfaite ou est exécuté trop tôt."
|
||||
prnt E " * $dep doit être exécuté avant $mod, vérifiez votre liste de modules."
|
||||
prnt E "Module $mod have unsatisfied dependencies or is executed too early."
|
||||
prnt E " * $dep must be executed before $mod, please check your module list."
|
||||
die 9
|
||||
fi
|
||||
done
|
||||
@@ -201,28 +207,28 @@ fi
|
||||
|
||||
# If we only checks, we stop here
|
||||
if [[ $CHECK_ONLY == true ]]; then
|
||||
prnt I "Mode de vérification seulement, on s'arrête là."
|
||||
prnt I "Checking mode only, not going any further."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $JUMP == true ]]; then
|
||||
prnt W "Les vérification sont évités, attention !"
|
||||
prnt W "Not doing any checks, please use with care!"
|
||||
else
|
||||
prnt I "Toutes les vérification ont été faites."
|
||||
prnt I "All checks have been run successfully."
|
||||
fi
|
||||
echo
|
||||
|
||||
if [[ $KEEPGOING == true ]]; then
|
||||
echo -e "${BRed}ATTENTION : Vous avez demandé la poursuite du script en cas d'erreur.${DEFAULTCOL}"
|
||||
echo -e "${BRed}ATTENTION : Cette option peut produires des résultats chaotiques.${DEFAULTCOL}"
|
||||
echo -e "${BRed}ATTENTION : Cette option ne devrait être utilisé que sur système de test.${DEFAULTCOL}"
|
||||
echo -e "${BRed}ATTENTION : You asked to continue the script even if error occurs.${DEFAULTCOL}"
|
||||
echo -e "${BRed}ATTENTION : That option could produce some chaotic results.${DEFAULTCOL}"
|
||||
echo -e "${BRed}ATTENTION : That option should be only used on test systems.${DEFAULTCOL}"
|
||||
echo
|
||||
fi
|
||||
echo -e "${BYellow}Si vous continuez après cette étape le système sera modifié !${DEFAULTCOL}"
|
||||
echo -e "${BYellow}If you continue after that step system will have changes!${DEFAULTCOL}"
|
||||
echo
|
||||
|
||||
dump_key_buffer
|
||||
read -n 1 -rsp $"Appuyer sur la touche <C> pour continuer ou une autre pour s'arrêter..." key
|
||||
read -n 1 -rsp $"Press <C> pour key to continue or an other one to stop now..." key
|
||||
echo
|
||||
|
||||
if [[ $key == "C" || $key == 'c' ]]; then
|
||||
@@ -233,14 +239,14 @@ if [[ $key == "C" || $key == 'c' ]]; then
|
||||
fi
|
||||
# We need this only if JUMP is set but doesn't matter if it's done again
|
||||
version=VER_$mod
|
||||
prnt I "Application des modifications pour $mod version ${!version}..."
|
||||
prnt I "Applying changes for $mod version ${!version}..."
|
||||
$mod
|
||||
echo $mod >> $STAGE_FILE # Mark as done for resuming function
|
||||
done
|
||||
unset mod
|
||||
echo
|
||||
else
|
||||
echo -e "${Yellow}Le système n'a subit aucune modifications.${DEFAULTCOL}"
|
||||
echo -e "${Yellow}The system has not undergone any modification.${DEFAULTCOL}"
|
||||
echo
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user