implemented chroot using bootstrap method
This commit is contained in:
@@ -274,6 +274,8 @@ The following table is giving a list of error code with explanation:
|
|||||||
| 11 | Bad function call |
|
| 11 | Bad function call |
|
||||||
| 12 | Error copying files |
|
| 12 | Error copying files |
|
||||||
| 13 | Bad target file system |
|
| 13 | Bad target file system |
|
||||||
|
| 14 | Impossible to chroot |
|
||||||
|
| 15 | Bad target filesystem/installation |
|
||||||
| 50..100 | Error in module execution |
|
| 50..100 | Error in module execution |
|
||||||
| 126 | Command exists but not executable |
|
| 126 | Command exists but not executable |
|
||||||
| 127 | Command not found |
|
| 127 | Command not found |
|
||||||
|
|||||||
4
init.sh
4
init.sh
@@ -116,6 +116,10 @@ fi
|
|||||||
# -- Cannot be a function ends here
|
# -- Cannot be a function ends here
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if [[ -n $CHROOT_PATH && -z $CHROOT_DONE ]]; then
|
||||||
|
chroot_bootstrap $@
|
||||||
|
fi
|
||||||
|
|
||||||
load_autoconf
|
load_autoconf
|
||||||
|
|
||||||
load_configuration
|
load_configuration
|
||||||
|
|||||||
@@ -139,6 +139,36 @@ read_commandline()
|
|||||||
export -f 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
|
# Automatically load system specific configuration if file exist in the
|
||||||
# following order:
|
# following order:
|
||||||
|
|||||||
Reference in New Issue
Block a user