ISO-repository/build/arm64.sh

46 lines
1.5 KiB
Bash
Raw Normal View History

2024-06-25 13:52:53 +00:00
#!/bin/sh
2022-05-25 10:37:22 +00:00
2024-06-25 12:00:48 +00:00
RASPIOS_IMG=2024-03-15-raspios-bookworm-arm64-lite.img
2022-05-25 10:37:22 +00:00
echo "Fetching image"
2024-06-25 12:00:48 +00:00
curl -O https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz
2022-05-25 10:37:22 +00:00
echo "Uncompressing image"
unxz $RASPIOS_IMG.xz
OFFSET_IMG=$(file $RASPIOS_IMG | cut -d';' -f3 | cut -d',' -f8 | cut -d' ' -f3)
mkdir -p mnt
echo "Mounting second partition"
2022-05-25 10:58:01 +00:00
sudo mount $RASPIOS_IMG -o offset=$((512*$OFFSET_IMG)) mnt
2022-05-25 10:37:22 +00:00
2024-06-25 13:18:26 +00:00
echo "Mounting necessary directories"
sudo mount -o bind /run mnt/run
sudo mount --rbind /dev mnt/dev
2022-05-25 10:37:22 +00:00
echo "Chroot into partition to start edition"
2022-05-25 10:58:01 +00:00
sudo chroot mnt /bin/sh <<"EOT"
2022-05-25 10:37:22 +00:00
2024-06-25 12:00:48 +00:00
/usr/sbin/usermod -l creator pi
/usr/sbin/usermod -d /home/creator -m creator
2022-05-25 14:11:11 +00:00
sed -i 's/creator:\*:/creator:\$6\$saltsalt\$EamwjkVXAe1WqiTTXuzgsmljl5cpVewMLH3xl8TdvQ\/V4S9e30upeNz2bdLkG5\.H71TCEso5Nl0jpyZRx7xy6\/:/g' /etc/shadow
2022-05-25 10:37:22 +00:00
sudo -u creator mkdir -p -m 700 /home/creator/.ssh
sudo -u creator sh -c 'echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDYsz4jdyzf9UcJ8eEavVmi+DNYE3ioeJBfTlVMw7Vsb tanguy@Diogenes" > /home/creator/.ssh/authorized_keys'
chmod 600 /home/creator/.ssh/authorized_keys
sed -i -E 's/#?PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
systemctl enable ssh
echo "kenoma" > /etc/hostname
echo "IP: \4" >> /etc/issue
2022-05-25 10:37:22 +00:00
EOT
2022-05-25 12:26:21 +00:00
echo "Unmounting second partition"
sudo umount mnt -R
2022-05-25 12:26:21 +00:00
2024-08-04 21:18:25 +00:00
CORE_COUNT=$((`nproc`-1))
2022-05-25 12:26:21 +00:00
echo "Compressing resulting image"
2024-08-04 21:18:25 +00:00
xz -T$CORE_COUNT $RASPIOS_IMG
2024-08-04 19:20:30 +00:00
2024-08-04 21:18:25 +00:00
mv $RASPIOS_IMG.xz halis-11.6.0-arm64.img.xz