-
Notifications
You must be signed in to change notification settings - Fork 0
/
fedberry-post.ks
106 lines (81 loc) · 2.76 KB
/
fedberry-post.ks
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
97
98
99
100
101
102
103
104
105
106
###
# Post-installation Scripts
###
### RPM & dnf related tweaking
%post
releasever=$(rpm -q --qf '%{version}\n' fedberry-release)
basearch=armhfp
# Work around for poor key import UI in PackageKit
rm -f /var/lib/rpm/__db*
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedberry-$releasever-primary
# Note that running rpm recreates the rpm db files which aren't needed or wanted
rm -f /var/lib/rpm/__db*
# remove random seed, the newly installed instance should make it's own
rm -f /var/lib/systemd/random-seed
### Remove various packages that refuse to not install themselves in the %packages sections :-/
dnf -y remove dracut-config-rescue
%end
### Having /tmp on tmpfs is enabled as this helps extend lifespan of sd cards
# However, size should be limited to 100M.
# This may cause issues for programs making heavy use of /tmp
%post
echo "Setting size limit of 100M for tmpfs for /tmp."
echo "tmpfs /tmp tmpfs defaults,noatime,size=100m 0 0" >>/etc/fstab
%end
### Remove uboot images after kernel installation
%post
echo "Cleaning up uboot images"
rm -f /boot/uI*
%end
### Enable usb boot support for RPi3(plus)
%post --nochroot
echo "Use PARTUUID in /boot/cmdline.txt"
PARTUUID=$(/usr/sbin/blkid -s PARTUUID |awk '/\/dev\/loop0p2/ { print $2 }' |sed 's/"//g')
sed -i "s|/dev/mmcblk0p2|$PARTUUID|" $INSTALL_ROOT/boot/cmdline.txt
%end
### Enable fsck for rootfs & boot partitions
%post
echo "Enabling fsck for rootfs & boot partitions"
#rootfs
sed -i 's| \/ \(.*\)0 0| \/ \10 1|' /etc/fstab
#boot
sed -i 's| \/boot \(.*\)0 0| \/boot \10 2|' /etc/fstab
%end
### Grow root filesystem on first boot
%post
echo "Enabling expanding of root partition on first boot"
touch /.rootfs-repartition
%end
### Create swap file
%post
echo "Creating 512 MB swap file..."
dd if=/dev/zero of=/swapfile bs=1M count=512
/usr/sbin/mkswap /swapfile
# world readable swap files are a local vulnerability!
chmod 600 /swapfile &>/dev/null
echo "/swapfile swap swap defaults 0 0" >>/etc/fstab
%end
### Tweak systemd options
%post
echo "Setting systemd DefaultTimeoutStopSec to 20secs"
sed -i 's/#DefaultTimeoutStopSec=90s/DefaultTimeoutStopSec=20s/' /etc/systemd/system.conf
%end
### Remove machine-id on pre generated images
%post
rm -f /etc/machine-id
touch /etc/machine-id
%end
### Some space saving cleanups
%post
echo "Zeroing out empty space."
# This forces the filesystem to reclaim space from deleted files
dd bs=1M if=/dev/zero of=/var/tmp/zeros || :
rm -f /var/tmp/zeros
echo "Available space on rootfs: $(df -h |awk '/loop0p2/ { print $4 }')"
%end
### List all installed packages, sorted by size
%post
echo "Installed packages sorted by size:"
rpm -qa --qf '%{SIZE} %{NAME}\n' | awk '{printf("%s Mb %s\n", $1 / 1000 / 1000, $2)}' | sort -k1 -n
%end