vcpi/prepare-image.sh

66 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2024-11-12 15:39:17 -05:00
#!/bin/bash
#
if [ -z "$1" ]
then
echo "No image name provided"
exit
fi
#download source
curl $1 --output src.img.xz
xz -v -T 0 -d src.img.xz
#setup
losetup -P /dev/loop8 src.img
mkdir -v /tmp/rpi-img
mount /dev/loop8p2 /tmp/rpi-img
mount /dev/loop8p1 /tmp/rpi-img/boot
#enable ssh
touch /tmp/rpi-img/boot/ssh
cp -v userconf.txt /tmp/rpi-img/boot/userconf
# pi user keys
mkdir /tmp/rpi-img/home/pi/.ssh
#echo "" > /tmp/rpi-img/home/pi/.ssh/authorized_keys
chown 1000:1000 /tmp/rpi-img/home/pi/.ssh
chown 1000:1000 /tmp/rpi-img/home/pi/.ssh/authorized_keys
#provision files
2024-11-12 15:39:17 -05:00
cp -v ./src/setup.sh /tmp/rpi-img/root/setup.sh
cp -v ./patch/native.vcv /tmp/rpi-img/root/native.vcv
2024-11-12 15:39:17 -05:00
#enable systemd-time-wait-sync
ln -v -s /lib/systemd/system/systemd-time-wait-sync.service /tmp/rpi-img/etc/systemd/system/sysinit.target.wants/systemd-time-wait-sync.service
2024-11-12 15:39:17 -05:00
#setup autorun on first boot
cp -v ./src/firstboot.service /tmp/rpi-img/lib/systemd/system/firstboot.service
ln -v -s /lib/systemd/system/firstboot.service /tmp/rpi-img/etc/systemd/system/multi-user.target.wants
2024-11-13 08:44:29 -05:00
# disable built-in audio
2024-11-13 09:03:02 -05:00
sed -i 's/^dtparam=audio=on/#&/' /tmp/rpi-img/boot/config.txt
2024-11-13 08:44:29 -05:00
# setup Cardinal
mkdir -v /tmp/rpi-img/opt/Cardinal
wget https://github.com/DISTRHO/Cardinal/releases/download/24.09/Cardinal-linux-aarch64-24.09.tar.gz -O /tmp/rpi-img/opt/Cardinal/Cardinal-linux-aarch64.tar.gz
tar -xzvf /tmp/rpi-img/opt/Cardinal/Cardinal-linux-aarch64.tar.gz -C /tmp/rpi-img/opt/Cardinal/ CardinalNative
# setup GUI payload
cp -v ./src/payload.service /tmp/rpi-img/lib/systemd/system/payload.service
ln -v -s /lib/systemd/system/payload.service /tmp/rpi-img/etc/systemd/system/graphical.target.wants
2024-11-13 08:54:42 -05:00
echo "] press enter to write the image"
2024-11-13 08:44:29 -05:00
read
2024-11-12 15:39:17 -05:00
sync
#cleanup
losetup -d /dev/loop8
umount /tmp/rpi-img/boot
umount /tmp/rpi-img
rmdir -v /tmp/rpi-img
#write image
2024-11-13 09:03:02 -05:00
mv -v src.img vcpi.img