Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Raspbian users #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ Example for RecalBox:
5. In the terminal, type the one-line command below(Case sensitive):

wget -O - "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/recalbox_install.sh" | bash

--------------------

Example for Raspbian:
1. Make sure internet connected.
2. Make sure keyboard connected.
3. In the terminal, type the one-line command below(Case sensitive):

wget -O - "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/raspbian_install.sh" | sudo bash
30 changes: 30 additions & 0 deletions raspbian_SafeShutdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
from gpiozero import Button, LED
import os
from signal import pause

powerPin = 3
resetPin = 2
ledPin = 14
powerenPin = 4
hold = 1
led = LED(ledPin)
led.on()
power = LED(powerenPin)
power.on()

#functions that handle button events
def when_pressed():
led.blink(.2,.2)
os.system("sudo shutdown -h now")
def when_released():
led.on()
def reboot():
os.system("sudo reboot")

btn = Button(powerPin, hold_time=hold)
rebootBtn = Button(resetPin)
rebootBtn.when_pressed = reboot
btn.when_pressed = when_pressed
btn.when_released = when_released
pause()
62 changes: 62 additions & 0 deletions raspbian_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash


#Step 1) Check if root--------------------------------------
if [[ $EUID -ne 0 ]]; then
echo "Please execute script as root."
exit 1
fi
#-----------------------------------------------------------

#Step 2) enable UART----------------------------------------
cd /boot/
File=config.txt
if grep -q "enable_uart=1" "$File";
then
echo "UART already enabled. Doing nothing."
else
echo "enable_uart=1" >> $File
echo "UART enabled."
fi
#-----------------------------------------------------------

#Step 3) Update repository----------------------------------
sudo apt-get update -y
#-----------------------------------------------------------

#Step 4) Install gpiozero module----------------------------
sudo apt-get install -y python3-gpiozero
#-----------------------------------------------------------

#Step 5) Download Python script-----------------------------
cd /opt/
sudo mkdir RetroFlag
cd /opt/RetroFlag
script=raspbian_SafeShutdown.py

if [ -e $script ];
then
echo "Script raspbian_SafeShutdown.py already exists. Doing nothing."
else
wget "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/raspbian_SafeShutdown.py"
fi
#-----------------------------------------------------------

#Step 6) Enable Python script to run on start up------------
cd /etc/
RC=rc.local

if grep -q "sudo python3 \/opt\/RetroFlag\/raspbian_SafeShutdown.py \&" "$RC";
then
echo "File /etc/rc.local already configured. Doing nothing."
else
sed -i -e "s/^exit 0/sudo python3 \/opt\/RetroFlag\/raspbian_SafeShutdown.py \&\n&/g" "$RC"
echo "File /etc/rc.local configured."
fi
#-----------------------------------------------------------

#Step 7) Reboot to apply changes----------------------------
echo "RetroFlag Pi Case installation done. Will now reboot after 3 seconds."
sleep 3
sudo reboot
#-----------------------------------------------------------