|
| 1 | +# Basic setup information |
| 2 | +url --mirrorlist="https://kitten.mirrors.almalinux.org/mirrorlist/10-kitten/baseos" |
| 3 | +# root password is locked but can be reset by cloud-init later |
| 4 | +rootpw --plaintext --lock almalinux |
| 5 | + |
| 6 | +# Repositories to use |
| 7 | +repo --name="baseos" --mirrorlist="https://kitten.mirrors.almalinux.org/mirrorlist/10-kitten/baseos" |
| 8 | +repo --name="appstream" --mirrorlist="https://kitten.mirrors.almalinux.org/mirrorlist/10-kitten/appstream" |
| 9 | +repo --name="raspberrypi" --mirrorlist="https://kitten.mirrors.almalinux.org/mirrorlist/10-kitten/raspberrypi" |
| 10 | + |
| 11 | +# install |
| 12 | +keyboard us --xlayouts=us --vckeymap=us |
| 13 | +timezone --isUtc --nontp UTC |
| 14 | +selinux --enforcing |
| 15 | +firewall --enabled --port=22:tcp |
| 16 | +network --bootproto=dhcp --device=link --activate --onboot=on |
| 17 | +services --enabled=sshd,NetworkManager,chronyd,bluetooth,cpupower |
| 18 | +shutdown |
| 19 | +bootloader --location=none |
| 20 | +lang en_US.UTF-8 |
| 21 | + |
| 22 | +# Disk setup |
| 23 | +clearpart --initlabel --all --disklabel=gpt |
| 24 | +part /boot --fstype=vfat --size=500 --label=cidata --ondisk=sda |
| 25 | +part / --fstype=ext4 --size=2400 --label=rootfs --ondisk=sda |
| 26 | + |
| 27 | +# Package setup |
| 28 | +%packages |
| 29 | +@core |
| 30 | +-caribou* |
| 31 | +-gnome-shell-browser-plugin |
| 32 | +-java-1.6.0-* |
| 33 | +-java-1.7.0-* |
| 34 | +-java-11-* |
| 35 | +-kernel-* |
| 36 | +-python*-caribou* |
| 37 | +NetworkManager-wifi |
| 38 | +almalinux-release-raspberrypi |
| 39 | +bluez |
| 40 | +chrony |
| 41 | +cloud-init |
| 42 | +cloud-utils-growpart |
| 43 | +e2fsprogs |
| 44 | +net-tools |
| 45 | +linux-firmware-raspberrypi |
| 46 | +raspberrypi-sys-mods |
| 47 | +raspberrypi-userland |
| 48 | +raspberrypi2-firmware |
| 49 | +raspberrypi2-kernel4 |
| 50 | +raspberrypi2-kernel4-tools |
| 51 | +raspberrypi2-kernel4-modules |
| 52 | +raspberrypi2-kernel4-modules-core |
| 53 | +raspberrypi2-kernel4-modules-extra |
| 54 | +nano |
| 55 | +libgpiod-utils |
| 56 | +%end |
| 57 | + |
| 58 | +%post |
| 59 | +# Mandatory README file |
| 60 | +cat >/boot/README.txt << EOF |
| 61 | +== AlmaLinux Kitten 10 == |
| 62 | +
|
| 63 | +To login to Raspberry Pi via SSH, you need to register SSH public key *before* |
| 64 | +inserting SD card to Raspberry Pi. Edit user-data file and put SSH public key |
| 65 | +in the place. |
| 66 | +
|
| 67 | +Default SSH username is almalinux. |
| 68 | +
|
| 69 | +EOF |
| 70 | +
|
| 71 | +# Data sources for cloud-init |
| 72 | +touch /boot/meta-data /boot/user-data |
| 73 | +
|
| 74 | +cat >/boot/user-data << "EOF" |
| 75 | +#cloud-config |
| 76 | +# |
| 77 | +# This is default cloud-init config file for AlmaLinux Raspberry Pi image. |
| 78 | +# |
| 79 | +# If you want additional customization, refer to cloud-init documentation and |
| 80 | +# examples. Please note configurations written in this file will be usually |
| 81 | +# applied only once at very first boot. |
| 82 | +# |
| 83 | +# https://cloudinit.readthedocs.io/en/latest/reference/examples.html |
| 84 | +
|
| 85 | +hostname: almalinux.local |
| 86 | +ssh_pwauth: false |
| 87 | +
|
| 88 | +users: |
| 89 | + - name: almalinux |
| 90 | + groups: [ adm, systemd-journal ] |
| 91 | + sudo: [ "ALL=(ALL) NOPASSWD:ALL" ] |
| 92 | + lock_passwd: false |
| 93 | + passwd: $6$EJCqLU5JAiiP5iSS$wRmPHYdotZEXa8OjfcSsJ/f1pAYTk0/OFHV1CGvcszwmk6YwwlZ/Lwg8nqjRT0SSKJIMh/3VuW5ZBz2DqYZ4c1 |
| 94 | + # Uncomment below to add your SSH public keys as YAML array |
| 95 | + #ssh_authorized_keys: |
| 96 | + #- ssh-ed25519 AAAAC3Nz... |
| 97 | +
|
| 98 | +EOF |
| 99 | +
|
| 100 | +cat > /boot/config.txt << EOF |
| 101 | +# This file is provided as a placeholder for user options |
| 102 | +# AlmaLinux - few default config options |
| 103 | +
|
| 104 | +[pi4] |
| 105 | +arm_boost=1 |
| 106 | +
|
| 107 | +[all] |
| 108 | +# enable serial console |
| 109 | +enable_uart=1 |
| 110 | +EOF |
| 111 | +
|
| 112 | +# Kernel command line string |
| 113 | +cat > /boot/cmdline.txt << EOF |
| 114 | +console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait |
| 115 | +EOF |
| 116 | +
|
| 117 | +# Create and initialize swapfile |
| 118 | +(umask 077; dd if=/dev/zero of=/swapfile bs=1M count=100) |
| 119 | +/usr/sbin/mkswap -p 4096 -L "_swap" /swapfile |
| 120 | +cat >> /etc/fstab << EOF |
| 121 | +/swapfile none swap defaults 0 0 |
| 122 | +EOF |
| 123 | +
|
| 124 | +# Remove ifcfg-link on pre generated images |
| 125 | +rm -f /etc/sysconfig/network-scripts/ifcfg-link |
| 126 | +
|
| 127 | +# rebuild dnf cache |
| 128 | +dnf clean all |
| 129 | +/bin/date +%Y%m%d_%H%M > /etc/BUILDTIME |
| 130 | +echo '%_install_langs C.utf8' > /etc/rpm/macros.image-language-conf |
| 131 | +echo 'LANG="C.utf8"' > /etc/locale.conf |
| 132 | +rpm --rebuilddb |
| 133 | +
|
| 134 | +# Remove machine-id on pre generated images |
| 135 | +rm -f /etc/machine-id |
| 136 | +touch /etc/machine-id |
| 137 | +%end |
| 138 | + |
| 139 | +%post --nochroot --erroronfail |
| 140 | +
|
| 141 | +LOOPPART=$(cat /proc/self/mounts |/usr/bin/grep '^\/dev\/mapper\/loop[0-9]p[0-9] '"$INSTALL_ROOT " | /usr/bin/sed 's/ .*//g') |
| 142 | +VFATPART=$(cat /proc/self/mounts |/usr/bin/grep '^\/dev\/mapper\/loop[0-9]p[0-9] '"$INSTALL_ROOT"/boot | /usr/bin/sed 's/ .*//g') |
| 143 | +echo "Found loop part for PARTUUID $LOOPPART" |
| 144 | +BOOTDEV=$(/usr/sbin/blkid $LOOPPART | egrep 'PARTUUID="([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})"' | sed 's/.*PARTUUID/PARTUUID/g;s/ .*//g;s/"//g') |
| 145 | +echo "no chroot selected bootdev=$BOOTDEV" |
| 146 | +if [ -n "$BOOTDEV" ];then |
| 147 | + cat $INSTALL_ROOT/boot/cmdline.txt |
| 148 | + echo sed -i "s|root=/dev/mmcblk0p2|root=${BOOTDEV}|g" $INSTALL_ROOT/boot/cmdline.txt |
| 149 | + sed -i "s|root=/dev/mmcblk0p2|root=${BOOTDEV}|g" $INSTALL_ROOT/boot/cmdline.txt |
| 150 | +fi |
| 151 | +
|
| 152 | +# cloud-init: NoCloud data source must have volume label "CIDATA" |
| 153 | +# |
| 154 | +# This didn't work for some reasons so using fatlabel instead. |
| 155 | +# part /boot --asprimary --fstype=vfat --mkfsoptions="-n CIDATA" |
| 156 | +/usr/sbin/fatlabel $VFATPART "CIDATA" |
| 157 | +# Kickstart sets the type of a VFAT partition with mountpoint /boot to EF00 |
| 158 | +# if a GUID partition table is used, so reset the partition type to 0700. |
| 159 | +VFATPARTNUM=$(echo ${VFATPART} | sed -n 's/.*p\([0-9]\+\)$/\1/p') |
| 160 | +VFATPARTDEV=$(echo ${VFATPART//\/mapper/} | sed 's/p[0-9]*$//') |
| 161 | +if [ -b "${VFATPARTDEV}p${VFATPARTNUM}" -o -b "${VFATPARTDEV}${VFATPARTNUM}" ]; then |
| 162 | +echo /usr/sbin/sgdisk --typecode="${VFATPARTNUM}:0700" ${VFATPARTDEV} |
| 163 | +/usr/sbin/sgdisk --typecode="${VFATPARTNUM}:0700" ${VFATPARTDEV} |
| 164 | +fi |
| 165 | +
|
| 166 | +/usr/sbin/sgdisk -p ${VFATPARTDEV} |
| 167 | +
|
| 168 | +cat $INSTALL_ROOT/boot/cmdline.txt |
| 169 | +
|
| 170 | +%end |
0 commit comments