How joseccnet/chroot-distros2 works
Purpose and execution model
This is a Bash-based Linux administration toolkit that creates and operates filesystem-isolated chroot environments under a configured jail root. It is not a service or web application: privileged users invoke scripts directly. Primary entry points are per-distribution builders, mount lifecycle management, cloning, deletion, and repository update scripts.
Paths: build-chroot-Debian.sh, mount_umount-chroot.sh, chroot.conf
Distribution build layer
Eight build entry points provision a named target filesystem for Debian-family and RPM-family distributions, accepting release and architecture selection. They encapsulate distribution-specific bootstrap/package-manager behavior, supported-release handling, optional custom mirrors, and cross-architecture targets.
Paths: build-chroot-Debian.sh, build-chroot-Ubuntu.sh, build-chroot-Centos.sh
Shared bootstrap contract
Builders share common shell behavior through the library and central configuration. chroot.conf defines the installation/jail policy consumed by scripts; lib/chroot-lib.sh is the likely common boundary for validation, logging, path handling, and reusable chroot operations. Environment variables are the main runtime override interface (for mirror, EOL, GPG, minimum space, and interactive behavior).
Paths: chroot.conf, lib/chroot-lib.sh, build-chroot-Fedora.sh
Repository and release metadata
RPM-family builds depend on checked-in repository definitions and yum/dnf configuration rather than only host defaults. This makes repository selection and legacy-release support part of the repository’s provisioning architecture. Linux Mint builds similarly carry per-release APT source and preference material.
Paths: centos/yumcentos.conf, fedora/fedora.repo, openSuse/repo-oss.repo
Mount lifecycle and runtime boundary
A created chroot becomes usable only after the mount manager attaches required host-backed filesystems. This stage supports individual and bulk mount/unmount, status inspection, dry-run behavior, idempotence, and logging. Its security boundary is hardened mount configuration, including restricted mount flags, slave propagation, and read-only /sys; it does not turn chroot into a security sandbox.
Paths: mount_umount-chroot.sh, chroot.conf, lib/chroot-lib.sh
Chroot lifecycle operations
Cloning duplicates an existing jail without repeat provisioning. Safe removal is deliberately separate from raw filesystem deletion: it validates targets, requires unmounting and explicit confirmation, and can enumerate available jails. Repository self-update is also an explicit administrative operation.
Paths: clone-chroot-Distro.sh, removeVM-chroot.sh, update_chroot-distros.sh
External dependencies and operational environment
The runtime is Linux with Bash 4.3+ and root privileges. Builders interact with distribution package ecosystems and remote mirrors—APT/debootstrap-style Debian-family sources and yum/dnf/zypper-style RPM-family repositories—while runtime uses kernel mount namespaces/filesystem mounts and the chroot command. Optional SSH use relies on generated chroot-compatible filesystem layout/configuration; process and resource limits remain inherited from the host.
Paths: ubuntu/trusty_etc_init.d_udev, centos/CentOS-Vault.repo, openSuse/repo-update.repo
Main entry points: chroot-lib.sh Shared shell library · build-chroot-Debian.sh Debian builder · build-chroot-Ubuntu.sh Ubuntu builder · build-chroot-Centos.sh RPM-family builders
Components 17
Administrative entry points
- Root Bash operator · Linux root user invokes toolkit scripts directly.
- Jail policy · Defines jail-root installation and mount policy.
chroot.conf - Shared shell library · Common validation, logging, paths, and chroot operations.
lib/chroot-lib.sh - Clone chroot · Duplicates an existing jail without provisioning again.
clone-chroot-Distro.sh - Safe removal · Requires an unmounted validated target and explicit confirmation.
removeVM-chroot.sh - Toolkit self-update
update_chroot-distros.sh
Provisioning
- Debian builder
build-chroot-Debian.sh - Ubuntu builder
build-chroot-Ubuntu.sh - RPM-family builders · Provision CentOS, Fedora, and related RPM targets.
build-chroot-Centos.sh - RPM repository definitions · Checked-in yum, dnf, and zypper repository selection supports legacy releases.
centos/yumcentos.conf - Debian-family mirrors · Remote APT/debootstrap sources selected by builder options and environment overrides.
Mounted chroot runtime
- Provisioned jail filesystem · Named distribution root created beneath the configured jail root.
- Mount lifecycle manager · Mounts, unmounts, inspects, and bulk-manages host-backed chroot filesystems.
mount_umount-chroot.sh - Host-backed mounts · Restricted flags, slave propagation, and read-only /sys support usable jails.
- Usable mounted chroot · Runs via chroot with host-inherited process and resource limits.
Other components
- Remote package mirrors · APT, yum/dnf, and zypper repositories supply target packages.
- Linux kernel and chroot · Provides mounts, namespaces, and the chroot command.
Connections 27
- Root Bash operator → Debian builder: invokes
- Root Bash operator → Ubuntu builder: invokes
- Root Bash operator → RPM-family builders: invokes
- Root Bash operator → Mount lifecycle manager: operates
- Root Bash operator → Clone chroot: invokes
- Root Bash operator → Safe removal: invokes
- Jail policy → Shared shell library: defines policy for
- Shared shell library → Debian builder: shared by
- Shared shell library → Ubuntu builder: shared by
- Shared shell library → RPM-family builders: shared by
- Shared shell library → Mount lifecycle manager: shared by
- Debian builder → Debian-family mirrors: selects
- Ubuntu builder → Debian-family mirrors: selects
- RPM-family builders → RPM repository definitions: uses
- Debian-family mirrors → Remote package mirrors: resolves
- RPM repository definitions → Remote package mirrors: resolves
- Debian builder → Provisioned jail filesystem: bootstraps
- Ubuntu builder → Provisioned jail filesystem: bootstraps
- RPM-family builders → Provisioned jail filesystem: provisions
- Mount lifecycle manager → Host-backed mounts: attaches and detaches
- Host-backed mounts → Usable mounted chroot: makes usable
- Provisioned jail filesystem → Usable mounted chroot: root filesystem for
- Linux kernel and chroot → Host-backed mounts: provides
- Linux kernel and chroot → Usable mounted chroot: executes
- Clone chroot → Provisioned jail filesystem: duplicates
- Safe removal → Provisioned jail filesystem: deletes after unmount
- Toolkit self-update → Debian builder: updates toolkit sources