meta-opi-diya/recipes-diya/diya-overlay/files/boot-to-recovery

21 lines
455 B
Plaintext
Raw Normal View History

2024-03-08 10:41:41 +01:00
#! /bin/sh
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "$0 shall be run as root"
exit 1
fi
. /etc/profile
if [ ! -e /boot/config.txt ]; then
# prepare env for recovery boot
cat << EOF > /boot/config.txt
recovery=true
recovery_image=recovery-${MACHINE}.cpio.gz
EOF
else
sed -i 's/^.*recovery.*/recovery=true/g' /boot/config.txt || \
echo "recovery=true" >> /boot/config.txt
fi
echo "Rebooting to recovery mode"
reboot