Build Your Own Arcade Controls Forum
Main => Raspberry Pi & Dev Board => Topic started by: Jefferson on March 05, 2016, 12:22:27 pm
-
Linux/Raspbian and command line work are not my strong suit so please bear with me...
'm having trouble installing the script for my mausberry shutdown switch (direct plug micro usb)
Following their instructions (http://mausberry-circuits.myshopify.com/pages/setup (http://mausberry-circuits.myshopify.com/pages/setup)) with my keyboard (not ssh) I managed to download setup.sh, although I had to omit the word sudo.
Now, when I enter "sudo bash setup.sh" I get:
"bash: sudo: command not found"
So I tried losing sudo again, with "bash setup.sh" I get:
setup.sh: line 22: sudo: command not found
setup.sh: line 23: sudo: command not found
I'm entering this in LXterminal on a dietpi (v58), Raspberry Pi 2 Model B... any help would be appreciated. I don't know if I'm at 'root' or not when I'm doing this. Once I clear this hurdle I can retire the mouse and keyboard from this project :)
-
You are using a different distro than the instructions are meant for. Not sure if the script will even run since you don't have the expected shell.
-
I was hoping since DietPi was basically a tiny Raspbian it'd fly. But if that's the problem... I'm bummed.
Any other safe shutdown solutions? Preferably using the same GPIO jumper arrangement I've got goin?
The Pi is awesomely small and affordable, but there have been a lot of workarounds.
-
I'm sure there's a way to make it work. DietPi makes some assumptions in order to minimize distro size. Assuming the basic user is root is one - that's why sudo doesn't work. You are already root.
-
Maybe you can try to edit the setup.sh script. (nano setup.sh) might work. Remove the sudo's from the script and save it. (Maybe keep an original copy as well) It depends how long the script is.
-
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
-
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.
-
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
-
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 &
-
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...
-
Welcome!