diff options
author | Tom Smeding <tom@tomsmeding.com> | 2022-06-14 18:15:40 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2022-06-14 18:15:40 +0200 |
commit | 30e9ed96f3a7683f6a23e689f666ef4a8948e3be (patch) | |
tree | e990949f5ab634cacb23ebbb74c2e9667e2640f9 /bwrap-files/make-chroot.sh |
Initial
Diffstat (limited to 'bwrap-files/make-chroot.sh')
-rwxr-xr-x | bwrap-files/make-chroot.sh | 31 |
1 files changed, 31 insertions, 0 deletions
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[@]}" |