-
Notifications
You must be signed in to change notification settings - Fork 0
/
classic.sh
executable file
·56 lines (49 loc) · 1.25 KB
/
classic.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# Run this script on an all-snap device to get quick-n-dirty version of the classic dimension
if [ "$(id -u)" -ne 0 ]; then
echo "this script needs to run as root"
exit 1
fi
case "$(uname -m)" in
i686)
arch=i386
;;
x86_64)
arch=amd64
;;
armv7l)
arch=armhf
;;
aarch64)
arch=arm64
;;
*)
echo "Unsupported architecture!"
exit 1
;;
esac
if [ ! -f "xenial-base-$arch.tar.gz" ]; then
echo "Downloading xenial chroot for $arch..."
python3 -c "from urllib.request import urlretrieve; urlretrieve('http://cdimage.ubuntu.com/ubuntu-base/xenial/daily/current/xenial-base-$arch.tar.gz', 'xenial-base-$arch.tar.gz')"
fi
if [ ! -d xenial ]; then
mkdir xenial
echo "Uncompressing xenial chroot..."
tar -zxf "xenial-base-$arch.tar.gz" -C xenial
fi
cleanup() {
umount -l xenial/home
umount -l xenial/sys
umount -l xenial/dev/pts
umount -l xenial/dev
umount -l xenial/proc
}
trap "cleanup" EXIT
mount --bind /proc xenial/proc
mount --bind /dev xenial/dev
mount --bind /sys xenial/sys
mount --bind /home xenial/home
mkdir -p xenial/dev/pts
mount -t devpts none xenial/dev/pts
cp /etc/resolv.conf xenial/etc
chroot xenial/