forked from open-edge-platform/edge-microvisor-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-tink-image.sh
More file actions
executable file
·72 lines (65 loc) · 2.7 KB
/
setup-tink-image.sh
File metadata and controls
executable file
·72 lines (65 loc) · 2.7 KB
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
#!/bin/bash
# Copyright (c) Intel Corporation.
# Licensed under the MIT License.
set -e
set -x
pprefix="Tink"
# services
systemctl disable systemd-homed.service
systemctl enable caddy.service
systemctl enable fluent-bit.service
mkdir -p /etc/fluent-bit
if [ ! -f /etc/fluent-bit/fluent-bit.conf ]; then
touch /etc/fluent-bit/fluent-bit.conf
fi
echo "$pprefix: fstab contents $(cat /etc/fstab)"
echo 'tmpfs / tmpfs defaults,size=1G 0 0' > /etc/fstab
echo "$pprefix: $(du -h /usr/share)"
find /usr/share -type f \
! -path "/usr/share/terminfo/v/vt100" \
! -path "/usr/share/terminfo/v/vt220" \
! -path "/usr/share/keymaps/include/*" \
! -path "/usr/share/keymaps/i386/include/*" \
! -path "/usr/share/keymaps/i386/qwerty/us.map.gz" \
! -path "/usr/share/consolefonts/lat9w-16*" \
! -path "/usr/share/dbus-1/system.conf" \
! -path "/usr/share/caddy/*" \
! -path "/usr/share/pki/*" \
! -path "/usr/share/p11-kit/*" \
! -path "/usr/share/licenses/*" \
-exec rm -f {} +
echo "$pprefix: reduced $(du -h /usr/share)"
ramfs=$(find /boot -type f -name initramfs*img -printf '%f\n')
# unzip initramfs
mkdir /tmp/initramfs
cd /tmp/initramfs
echo "$pprefix: inside $(pwd)"
echo "$pprefix: unziping initial initramfs for repack"
gunzip -c -k /boot/$ramfs | cpio -idmv --no-absolute-filenames
echo "$pprefix: free space $(df -h)"
cd /tmp/initramfs
echo "$pprefix: inside $(pwd)"
echo "$pprefix: after copy $(du -h /tmp/initramfs)"
echo "$pprefix: check cmdline.d $(ls etc/cmdline.d)"
echo "$pprefix: check cmdline.d contents $(cat etc/cmdline.d/95root-dev.conf)"
echo 'root=tmpfs rootflags=size=1G,mode=0755' > etc/cmdline.d/95root-dev.conf
echo "$pprefix: check cmdline.d contents after edit $(cat etc/cmdline.d/95root-dev.conf)"
echo "$pprefix: before rm devexist* $(ls -al var/lib/dracut/hooks/initqueue/finished/)"
rm -f var/lib/dracut/hooks/initqueue/finished/devexists*
echo "$pprefix: after rm devexist* $(ls -al var/lib/dracut/hooks/initqueue/finished/)"
echo "$pprefix: before rm wants $(ls -al etc/systemd/system/initrd.target.wants/)"
rm -rf etc/systemd/system/initrd.target.wants/dev-disk-b*
echo "$pprefix: after rm wants $(ls etc/systemd/system/initrd.target.wants/)"
echo "$pprefix: before rm disk service $(ls -al etc/systemd/system/dev-disk-b*)"
rm -rf etc/systemd/system/dev-disk-b*
echo "$pprefix: after rm disk service $(ls -al etc/systemd/system/)"
echo "$(find . -iname dev-disk*)"
# copy tar required for uncompressing rootfs archive
echo "$pprefix: before copy tar $(find . -iname tar)"
cp /usr/bin/tar usr/bin
echo "$pprefix: after copy tar $(find . -iname tar)"
#mv /rootfs.tar.gz /tmp/initramfs/
find . | cpio -o -H newc | gzip > /boot/$ramfs
cd -
echo "$pprefix: $(ls -l /boot/$ramfs)"
rm -rf /tmp/initramfs