From 30e9ed96f3a7683f6a23e689f666ef4a8948e3be Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 14 Jun 2022 18:15:40 +0200 Subject: Initial --- bwrap-files/make-chroot.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 bwrap-files/make-chroot.sh (limited to 'bwrap-files/make-chroot.sh') diff --git a/bwrap-files/make-chroot.sh b/bwrap-files/make-chroot.sh new file mode 100755 index 0000000..d29d1af --- /dev/null +++ b/bwrap-files/make-chroot.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd "$(dirname "$0")" + +basedir=ubuntu-base + +[[ ($# -le 0 || "$1" != "-f") && -d "$basedir" ]] && { + echo >&2 "Warning: base directory already exists, use -f to force" + exit 1 +} + +mkdir -p "$basedir" +curl -L 'http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04.1-base-amd64.tar.gz' | tar -C "$basedir" -xz + +args=( + --bind ubuntu-base / + --ro-bind /etc/resolv.conf /etc/resolv.conf + --tmpfs /tmp + --dev /dev + --proc /proc + --new-session + --unshare-all + --share-net + --die-with-parent + --gid 0 --uid 0 + --chdir / + --ro-bind chroot-initialise.sh /tmp/chinit.sh + /bin/bash /tmp/chinit.sh +) +bwrap "${args[@]}" -- cgit v1.2.3-70-g09d2