#! /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