#!/bin/bash
# Fix the NEO Pi GPIO reset when boot
# @BI7JTA 2025.1.14
# sudo curl https://www.bi7jta.org/files/AndyTaylorTweet/updateScripts/Patch_fix_NanoPiNEO-4.2x-GIPO-Reset-onBoot.sh | sudo sh

if [ "$(id -u)" != "0" ]; then
  echo -e "You need to be root to run this command...\n"
  exit 1
fi


# Remount root as writable
sudo mount -o remount,rw /  

cd ~

rm rc.local-with-gpio-fixed-4.2.0  

curl -OL https://www.bi7jta.org/files/AndyTaylorTweet/updateScripts/patch/NEO/rc.local-with-gpio-fixed-4.2.0;  
ls -l 

sh install-python3-rpi.gpio.sh 
cp rc.local-with-gpio-fixed-4.2.0 /etc/rc.local 
 
cat /etc/rc.local 

sudo mount -o remount,ro /  

echo "All Done, reboot will be fixed the GPIO reset for NEO Pi, version 4.x +" 
echo "Please run: sudo reboot"
