Hey everyone, thanks a bunch for all of the help thus far. Hopefully someday I will understand these systems much better then i currently do…
I am trying to run a script to initiate the shutdown sequence when the ff switch is triggered. I had no issue getting this to work on Noobs, but will not work on DietPi. I am using a Mausberry Circuits car switch, and going through their listed method to install the script. So far, it will not run.
#this is the GPIO pin connected to the lead on switch labeled OUT
GPIOpin1=23
#this is the GPIO pin connected to the lead on switch labeled IN
GPIOpin2=24
echo “$GPIOpin1” > /sys/class/gpio/export
echo “in” > /sys/class/gpio/gpio$GPIOpin1/direction
echo “$GPIOpin2” > /sys/class/gpio/export
echo “out” > /sys/class/gpio/gpio$GPIOpin2/direction
echo “1” > /sys/class/gpio/gpio$GPIOpin2/value
while [ 1 = 1 ]; do
power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
if [ $power = 0 ]; then
sleep 1
else
sudo poweroff
fi
done’ > /etc/switch.sh
sudo chmod 777 /etc/switch.sh
sudo sed -i ‘$ i /etc/switch.sh &’ /etc/rc.local
I have tried several methods to run the script, but I am getting a number of error such as
root@DietPi:~# sudo bash setup.sh
setup.sh: line 1: !DOCTYPE: No such file or directory
setup.sh: line 2: syntax error near unexpected token newline' setup.sh: line 2: “http://www.w3.org/TR/html4/strict.dtd”>’
root@DietPi:~#
I am outclassed here. This is way beyond my knowledge to modify, change, or even understand what is wrong…Is there something so vastly different about DietPI that would make this work in Noobs but not this?
I thought i might revisit this one last time to see if anyone had any insight into why this script wouldn’t run on dietpi, but has no issue on Rasberry Pi NOOBS, the new Raspberry Pi OS, and i would imagine several other distros.
I moved back tousing NOOBS for my dashboard simply because this script would run properly for my auto shut down switch in my car. That being said, i REALLY liked how quickly dietPi would boot…I would very much like to get this running before i put the dash back into the car this week.
Ok, thats good to know. Now with that being said, i wish i knew what that did or what to replace it with. Is this something I can replace something else? If i understand correctly, rc.local is for auto starting things? Is there something else DietPi uses that i could replace that part with?
Thanks for that. I will look into it. If I can make this work, it might be worth redoing my dash for the 4th time this week. 50 second bootup to loading the tuning software dashboard on the car is a bit hard to swallow, even for a dedicated race car.
root@DietPi:~# sudo bash setup.sh
setup.sh: line 1: !DOCTYPE: No such file or directory
setup.sh: line 2: syntax error near unexpected token newline' setup.sh: line 2: "> http://www.w3.org/TR/html4/strict.dtd> ">’
root@DietPi:~#
Aside of the rc.local topic, the syntax error looks like you tried to download the script but downloaded a raw HTML document instead. This happens regularly to me when I try to run this script via