Main > Raspberry Pi & Dev Board

Mausberry shutdown switch issue

<< < (2/3) > >>

Jefferson:
obcd: that seems right.  I went into the script, and sure enough "sudo" appears on lines 22 and 23.  I deleted em.  In terminal I entered "bash setup.sh" and it just gave me a new line in the terminal.  No readout or anything.  I entered "reboot" per the instructions and afterward... the switch didn't work.  Hm.

The script lines in question are:
sudo chmod 777 /etc/switch.sh
sudo sed -i '$ i /etc/switch.sh &' /etc/rc.local

Is it trying to refer to a switch.sh file as well? I couldn't seem to find one. Maybe that's the issue?  Ugh.

J

Jefferson:
ok I found /etc and I found switch.sh... it's script is exactly the same except for " echo ' " at the beginning of line 1 is missing, and the last two lines are missing:
sudo chmod 777 /etc/switch.sh
sudo sed -i '$ i /etc/switch.sh &' /etc/rc.local

switch.sh is also an executable file.

I'll monkey around with these findings.  I'm sure this is easy if you know your way around Linux, so if you're reading this and laughing at me, please throw me a freakin bone.

Jefferson:
Alright, I executed switch.sh.  Nothing.  Executed it "in Terminal"... and I get this:

/etc/switch.sh: line 9: echo: write error: Device or resource busy
/etc/switch.sh: line 11: echo: write error: Device or resource busy
/etc/switch.sh: line 12: echo: write error: Input/output error
/etc/switch.sh: line 13: echo: write error: Operation not permitted


For discussion, here's the script for switch.sh:
#!/bin/bash

#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

nitrogen_widget:
I think this is what you need to look at in order to kill the GPIO app running in the background at boot.

run:

nano /etc/rc.local from the root directory.

find the below line & remove it or put # in front to comment it out then reboot & try your mausberry app again.

/home/pi/Raspicade-Retrogame-2Player-BPlus/retrogame &

Jefferson:
Hey Nitro, when I run that, what I got was:

#!/bin/sh -e
#
# rc.local

/boot/dietpi/boot
/usr/local/bin/retrogame &
/etc/switch.sh &
/etc/switch.sh &
/etc/switch.sh &
/etc/switch.sh &
exit 0

So I commented out the closest thing, "retrogame &" and it seems I was able to run my bash setup.sh (in which I had removed the sudos) ... again no confirmation screen or anything, just starts a new line in the terminal. Restarted and IT WORKED!  Thanks all.  On to the next hurdle...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version