implemented chroot using bootstrap method

This commit is contained in:
levasseur
2021-10-22 17:15:01 +02:00
parent 2693a3cc72
commit 476aa67daa
3 changed files with 36 additions and 0 deletions

View File

@@ -139,6 +139,36 @@ read_commandline()
export -f read_commandline
# ------------------------------------------------------------------------------
# If chrooted, we need to bootstrap to a new copy of our directory tree
chroot_bootstrap()
{
if [[ ! -d $CHROOT_PATH ]]; then
prnt E "The path given to chroot don't exists."
die 14
fi
if [[ ! -d $CHROOT_PATH/tmp ]]; then
prnt E "The target filesystem doesn't seems to be a valid installation."
die 15
fi
local tmpdir=$(mktemp -d $CHROOT_PATH/tmp/init.sh-XXXX)
local bootstrap_items="conf lib modules repo bash.rc init.sh"
if [[ $RESUME == true ]]; then
bootstrap_items="$bootstrap_items $STAGE_FILE"
fi
prnt I "Préparation du changement de racine."
cp -av $bootstrap_items $tmpdir
prnt I "Changement de racine et démarrage d'un fork d'init.sh..."
chroot $CHROOT_PATH /bin/bash -c 'CHROOT_DONE=true; $tmpdir/init.sh $@'
prnt I "Retours au système hote et nettoyage."
rm -rf $tmpdir
exit 0
}
# ------------------------------------------------------------------------------
# Automatically load system specific configuration if file exist in the
# following order: