Skip to content

Instantly share code, notes, and snippets.

@quantum5
Created October 20, 2021 06:05
Show Gist options
  • Save quantum5/c55573e2261c63e401463d71865da3f0 to your computer and use it in GitHub Desktop.
Save quantum5/c55573e2261c63e401463d71865da3f0 to your computer and use it in GitHub Desktop.
Script to instantly create a temporary fresh install of Debian, no root access required (needs fakechroot, fakeroot, debootstrap)
#!/bin/bash
set -euo pipefail
assure_command() {
if ! command -v "$1" &> /dev/null; then
echo "$1 is required to run this script"
echo "Run: apt install $1"
exit 1
fi
}
assure_command fakechroot
assure_command fakeroot
DIR="$(mktemp -d)"
cleanup() {
rm -rf "$DIR"
}
trap cleanup EXIT
SUITE="${1:-stable}"
echo "Installing debian $SUITE..."
fakechroot fakeroot debootstrap "$SUITE" "$DIR"
fakechroot fakeroot chroot "$DIR" /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment