server/configs/update_imgs.sh

36 lines
991 B
Bash
Raw Normal View History

2018-12-10 01:16:07 +00:00
#!/bin/sh
mkdir -p /boot/imgs
# 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
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
wget -O "/boot/imgs/${img}" "$1/${img}"
2018-12-10 01:16:07 +00:00
done
# 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
/bin/ash
sync
reboot -f
done
}
2023-10-23 16:27:00 +00:00
umount "${ISO}"
dd if=/boot/imgs/fickit-metadata.iso of="$2"