Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Mausberry shutdown switch issue  (Read 4750 times)

0 Members and 1 Guest are viewing this topic.

Jefferson

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 169
  • Last login:January 14, 2024, 08:50:59 pm
Mausberry shutdown switch issue
« 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) 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 :)

Slippyblade

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3167
  • Last login:June 05, 2024, 10:30:57 am
  • And to the death god we say, "Not today!"
Re: Mausberry shutdown switch issue
« Reply #1 on: March 05, 2016, 12:27:07 pm »
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.

Jefferson

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 169
  • Last login:January 14, 2024, 08:50:59 pm
Re: Mausberry shutdown switch issue
« Reply #2 on: March 05, 2016, 03:04:07 pm »
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.

Slippyblade

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3167
  • Last login:June 05, 2024, 10:30:57 am
  • And to the death god we say, "Not today!"
Re: Mausberry shutdown switch issue
« Reply #3 on: March 05, 2016, 04:53:48 pm »
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.

obcd

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 160
  • Last login:April 03, 2019, 11:44:36 am
  • I want to build my own arcade controls!
Re: Mausberry shutdown switch issue
« Reply #4 on: March 06, 2016, 06:13:53 am »
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.

Jefferson

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 169
  • Last login:January 14, 2024, 08:50:59 pm
Re: Mausberry shutdown switch issue
« Reply #5 on: March 10, 2016, 01:32:52 pm »
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

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 169
  • Last login:January 14, 2024, 08:50:59 pm
Re: Mausberry shutdown switch issue
« Reply #6 on: March 10, 2016, 01:48:14 pm »
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

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 169
  • Last login:January 14, 2024, 08:50:59 pm
Re: Mausberry shutdown switch issue
« Reply #7 on: March 10, 2016, 02:02:46 pm »
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

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1782
  • Last login:May 23, 2025, 02:30:58 pm
  • I want to build my own arcade controls!
Re: Mausberry shutdown switch issue
« Reply #8 on: March 11, 2016, 09:55:23 am »
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

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 169
  • Last login:January 14, 2024, 08:50:59 pm
Re: Mausberry shutdown switch issue
« Reply #9 on: March 14, 2016, 01:16:42 pm »
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...

nitrogen_widget

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1782
  • Last login:May 23, 2025, 02:30:58 pm
  • I want to build my own arcade controls!
Re: Mausberry shutdown switch issue
« Reply #10 on: March 14, 2016, 04:17:50 pm »
Welcome!