diff --git a/README.md b/README.md index 604acbe..51c8163 100644 --- a/README.md +++ b/README.md @@ -151,14 +151,19 @@ There are three main ways to update Conty and get the latest packages, use which ## How to create your own Conty executables -If you want to create Arch-based container, use the **create-arch-bootstrap.sh** script, it will download latest Arch Linux bootstrap and will install latest packages into it. If you want to use any other distro, then you need to manually obtain it from somewhere. Root rights are required for this step, because chroot is used here. +If you want to create an Arch-based container, use the **create-arch-bootstrap.sh** script, it will download latest Arch Linux bootstrap and will install latest packages into it. If you want to use any other distro, then you need to manually obtain it from somewhere. Root rights are required for this step, because chroot is used here. ``` ./create-arch-bootstrap.sh ``` You can edit the script if you want to include different set of packages inside the container. -When distro is obtained, use the **create-conty.sh** script to create a squashfs (or dwarfs) image and pack everything needed into a single executable. +When distro is obtained, you can use the **enter-chroot.sh** script to chroot +into the bootstrap and do some manual modifications (for instance, modify some +files, install/remove packages, etc.). This step is optional and you can +skip it if you don't need it. + +After that use the **create-conty.sh** script to create a squashfs (or dwarfs) image and pack everything needed into a single executable. ``` ./create-conty.sh ``` diff --git a/enter-chroot.sh b/enter-chroot.sh new file mode 100755 index 0000000..16c08a2 --- /dev/null +++ b/enter-chroot.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Root rights are required + +if [ $EUID != 0 ]; then + echo "Root rights are required!" + + exit 1 +fi + +script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +bootstrap="${script_dir}"/root.x86_64 + +if [ ! -d "${bootstrap}" ]; then + echo "Bootstrap is missing" + exit 1 +fi + +# First unmount just in case +umount -Rl "${bootstrap}" + +mount --bind "${bootstrap}" "${bootstrap}" +mount -t proc /proc "${bootstrap}"/proc +mount --bind /sys "${bootstrap}"/sys +mount --make-rslave "${bootstrap}"/sys +mount --bind /dev "${bootstrap}"/dev +mount --bind /dev/pts "${bootstrap}"/dev/pts +mount --bind /dev/shm "${bootstrap}"/dev/shm +mount --make-rslave "${bootstrap}"/dev + +rm -f "${bootstrap}"/etc/resolv.conf +cp /etc/resolv.conf "${bootstrap}"/etc/resolv.conf + +mkdir -p "${bootstrap}"/run/shm + +echo "Entering chroot" +echo "To exit the chroot, perform the \"exit\" command" +chroot "${bootstrap}" /usr/bin/env LANG=en_US.UTF-8 TERM=xterm PATH="/bin:/sbin:/usr/bin:/usr/sbin" /bin/bash +echo "Exiting chroot" + +umount -l "${bootstrap}" +umount "${bootstrap}"/proc +umount "${bootstrap}"/sys +umount "${bootstrap}"/dev/pts +umount "${bootstrap}"/dev/shm +umount "${bootstrap}"/dev