-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-pkgs-2
96 lines (86 loc) · 2.95 KB
/
install-pkgs-2
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
export DEBIAN_FRONTEND="noninteractive"
mkdir -p /usr/local/bin/
cp /mnt/nerdctl /usr/bin
cp /mnt/containerd-stargz-grpc /usr/local/bin
cp /mnt/ctr-remote /usr/bin
chmod +x /usr/bin/nerdctl
chmod +x /usr/local/bin/containerd-stargz-grpc
chmod +x /usr/bin/ctr-remote
cp -rv /mnt/stargz-config/* /
echo "" > /etc/containerd-stargz-grpc/config.toml
echo "ipfs = true" >> /etc/containerd-stargz-grpc/config.toml
echo "no_background_fetch = true" >> /etc/containerd-stargz-grpc/config.toml
echo "disable_verification = true" >> /etc/containerd-stargz-grpc/config.toml
cat > /etc/systemd/network/20-eth0.network << EOF
[Match]
Name=eth0
[Network]
DHCP=yes
[Link]
RequiredForOnline=no
ActivationPolicy=always-up
EOF
systemctl enable stargz-snapshotter
systemctl enable systemd-networkd.service
echo -n "Enabled.."
mkdir -p /usr/bin/
cat > /usr/bin/cartesi-run-app.sh << EOF
#!/bin/bash
export IPFS_PATH=/root/.ipfs
export HTTP_DATASTORE_URL=http://127.0.0.1:5005/ipfs
export IO_DEVICE=/dev/pmem1
mkdir -p /opt/rollup-store
mkdir -p /opt/rollup-cache
/usr/bin/ipfs init /etc/ipfs-config
/usr/bin/ipfs daemon --offline &
echo "Waiting for IPFS"
IPFS_HOST="127.0.0.1"
IPFS_PORT="5001"
while true; do
nc -z "\$IPFS_HOST" "\$IPFS_PORT"
RET=\$?
echo \$RET
if [ x\$RET = x0 ]; then
break
fi
sleep 1
done
echo "IPFS up"
echo "Asking for app to guest tools which would set CID of /app"
curl http://127.0.0.1:5005/get_app > /dev/null
ipfs files read /app/boot-script > /tmp/boot-script
chmod +x /tmp/boot-script
cat /tmp/boot-script
/tmp/boot-script
EOF
chmod +x /usr/bin/cartesi-run-app.sh
find /usr/share/doc -depth -type f ! -name copyright|xargs rm || true
find /usr/share/doc -empty|xargs rmdir || true
rm -rf /usr/share/groff/* /usr/share/info/*
rm -rf /usr/share/lintian/* /usr/share/linda/* /var/cache/man/*
rm -rf /var/cache/apt/*.bin
mv /usr/share/locale/en /tmp/en
rm -rf /usr/share/locale/*
rm -rf /usr/share/consolefonts/*
mv /tmp/en /usr/share/locale/en
locale-gen
dpkg --remove ubuntu-minimal
dpkg --remove ubuntu-advantage-tools
dpkg --purge python3.10 python3 netplan.io lsb-release networkd-dispatcher python3-apt python3-dbus python3-gi python3-netifaces python3-pkg-resources python3-yaml libpython3-stdlib:riscv64 libpython3.10-stdlib python3.10-minimal python3-minimal
find /usr/share/i18n/charmaps/ -type f ! -name UTF-8.gz -delete
find /usr/share/i18n/locales/ -type f ! -name en_US ! -name en_GB ! -name i18n* ! -name iso14651_t1 ! -name iso14651_t1_common ! -name 'translit_*' -delete && echo 'en_US.UTF-8 UTF-8' > /usr/share/i18n/SUPPORTED
rm -rf /usr/share/man/* /usr/share/doc/* /usr/share/X11/*
cat > /etc/fstab << EOF
/dev/pmem0 / ext4 defaults,noatime,ro 1 1
EOF
mkfs.ext4 -O ^has_journal /dev/pmem2
mkdir -p /dev/tmp
mount -t tmpfs tmpfs /dev/tmp
mkdir -p /dev/tmp/mnt
mount /dev/pmem2 /dev/tmp/mnt
tar --one-file-system -pcf - / | tar -C /dev/tmp/mnt/ -xf -
umount /dev/tmp/mnt
sync