Created
October 20, 2021 06:05
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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