2018-12-10 01:16:07 +00:00
#!/bin/sh
mkdir -p /boot/imgs
2023-10-23 15:32:40 +00:00
# Backup the previous metadata
2024-03-24 10:42:11 +00:00
/usr/bin/metadata -v cdrom
2023-10-23 16:43:33 +00:00
mv /boot/imgs/fickit-metadata.iso /boot/imgs/fickit-metadata.iso.bak
2023-10-23 15:32:40 +00:00
2023-10-22 10:47:44 +00:00
for img in fickit-boot-kernel fickit-metadata.iso fickit-boot-initrd.img fickit-prepare-initrd.img fickit-frontend-squashfs.img fickit-backend-squashfs.img fickit-update-initrd.img
2018-12-10 01:16:07 +00:00
do
2022-06-02 10:02:38 +00:00
wget -O " /boot/imgs/ ${ img } " " $1 / ${ img } "
2018-12-10 01:16:07 +00:00
done
2023-10-23 15:32:40 +00:00
# Check dm-crypt key not changed
ISO = $( mktemp -d)
mount /boot/imgs/fickit-metadata.iso " ${ ISO } "
NEW_KEY = $( sed -rn 's/.*"content": "([^"]+)"$/\1/p' " ${ ISO } /user-data " | head -n 1)
OLD_KEY = $( cat /run/config/dm-crypt/key)
[ " ${ NEW_KEY } " != " ${ OLD_KEY } " ] && {
read -p "DM-CRYPT key changed in metadata, are you sure you want to erase it? (y/N) " V
2023-10-23 15:55:10 +00:00
[ " $V " != "y" ] && [ " $V " != "Y" ] && while true; do
echo
echo "Metadata drive not erased"
echo
2023-10-23 15:32:40 +00:00
/bin/ash
2024-03-24 11:29:11 +00:00
sync
reboot -f
2023-10-23 15:32:40 +00:00
done
}
2023-10-23 16:27:00 +00:00
umount " ${ ISO } "
2023-10-23 15:32:40 +00:00
dd if = /boot/imgs/fickit-metadata.iso of = " $2 "