begining work on the chroot option

This commit is contained in:
levasseur
2021-10-15 18:39:16 +02:00
parent 5fd16fbd69
commit 53c546fe20
3 changed files with 19 additions and 0 deletions

View File

@@ -157,6 +157,10 @@ isdirempty()
{ {
dir=$1 dir=$1
if [[ -f $dir ]]; then
prnt E "isdirempty():The given parameter is not a directory."
die 15
fi
if [[ ! -d $dir ]]; then if [[ ! -d $dir ]]; then
return 0 return 0
fi fi

View File

@@ -35,10 +35,13 @@ Options :
-R, --no-root-check Ne pas vérifier les droits root (ou UID 0) -R, --no-root-check Ne pas vérifier les droits root (ou UID 0)
-P, --no-proxy Ne pas utiliser de proxy lors de l'utilisation de -P, --no-proxy Ne pas utiliser de proxy lors de l'utilisation de
ce script (n'empêche pas leur configuration via modules) ce script (n'empêche pas leur configuration via modules)
-D, --no-deps Ne pas vérifier les dépendances entre les modules.
-h, --help Affiche ce texte d'aide. -h, --help Affiche ce texte d'aide.
-s, --shell Lance un shell avec tout l'environnement du script pour -s, --shell Lance un shell avec tout l'environnement du script pour
débogage. Aucune action ou vérification n'est faite en débogage. Aucune action ou vérification n'est faite en
dehors des commandes lancées dans le shell. dehors des commandes lancées dans le shell.
--chroot <chemin> Permet à init de ne pas appliquer les modifications au
système de fichier racine mais à un système différent.
-l, --logfile <nom> Nom du fichier de log. Peut aussi être changé -l, --logfile <nom> Nom du fichier de log. Peut aussi être changé
via la variable d'environnement LOGFILE. via la variable d'environnement LOGFILE.
-v, --version Affiche la version de ce script et celles de -v, --version Affiche la version de ce script et celles de

View File

@@ -24,6 +24,7 @@ read_commandline()
local want_module=false local want_module=false
local want_logfile=false local want_logfile=false
local want_conffile=false local want_conffile=false
local want_conffile=false
local opt= local opt=
for opt in $@; do for opt in $@; do
@@ -75,10 +76,14 @@ read_commandline()
"-s"|"--shell") "-s"|"--shell")
export RUN_SHELL=true export RUN_SHELL=true
;; ;;
"--chroot")
local want_chroot
;;
*) *)
if [[ $want_module == true ]]; then if [[ $want_module == true ]]; then
[[ $want_logfile == true ]] && synthax_error [[ $want_logfile == true ]] && synthax_error
[[ $want_conffile == true ]] && synthax_error [[ $want_conffile == true ]] && synthax_error
[[ $want_chroot == true ]] && synthax_error
if [[ -z $MANUAL_MODULE_LIST ]]; then if [[ -z $MANUAL_MODULE_LIST ]]; then
export MANUAL_MODULE_LIST=$opt export MANUAL_MODULE_LIST=$opt
want_module=false want_module=false
@@ -90,6 +95,7 @@ read_commandline()
elif [[ $want_logfile == true ]]; then elif [[ $want_logfile == true ]]; then
[[ $want_module == true ]] && synthax_error [[ $want_module == true ]] && synthax_error
[[ $want_conffile == true ]] && synthax_error [[ $want_conffile == true ]] && synthax_error
[[ $want_chroot == true ]] && synthax_error
if [[ -z $NEW_LOGFILE ]]; then if [[ -z $NEW_LOGFILE ]]; then
export NEW_LOGFILE=$opt export NEW_LOGFILE=$opt
want_logfile=false want_logfile=false
@@ -100,8 +106,14 @@ read_commandline()
elif [[ $want_conffile == true ]]; then elif [[ $want_conffile == true ]]; then
[[ $want_module == true ]] && synthax_error [[ $want_module == true ]] && synthax_error
[[ $want_logfile == true ]] && synthax_error [[ $want_logfile == true ]] && synthax_error
[[ $want_chroot == true ]] && synthax_error
export CONFFILES="$CONFFILES $opt" export CONFFILES="$CONFFILES $opt"
want_logfile=false want_logfile=false
elif [[ $want_chroot == true ]]; then
[[ $want_module == true ]] && synthax_error
[[ $want_logfile == true ]] && synthax_error
[[ $want_conffile == true ]] && synthax_error
# To be finished
else else
prnt E "Paramètre \"$opt\" non géré." prnt E "Paramètre \"$opt\" non géré."
die 1 --force die 1 --force