#!/bin/sh



ver_num=$(lsb_release -a 2>/dev/null | grep Release | awk  '{ print $2; }')
if (( $ver_num < 12 ))
then
        BOOT_DIR="/boot"
else
        BOOT_DIR="/boot/firmware"
fi


if [ -e /mnt/boot-ro/config.txt ]; then
    echo Already write protected
else
    sudo grep -v initramfs ${BOOT_DIR}/config.txt >/tmp/config.txt
    sudo echo initramfs initrd.gz >> /tmp/config.txt
    sudo cp /tmp/config.txt ${BOOT_DIR}/config.txt
    sudo reboot
fi

