blob: d29d1af3a581c38505e2391a8008a363d59fb0cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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[@]}"
|