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 Ubuntu #7

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
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Section 1**\
Installers for NesPi+, MegaPi, SuperPi cases and (since 2020/08/22) **NESPI4**
Support for RetroPie, RecalBox and BATOCERA
Support for RetroPie, RecalBox, BATOCERA, and Ubuntu!

**Section 2**\
Installer for the GPi case\
Expand All @@ -11,7 +11,7 @@ Support for RetroPie and BATOCERA
**Section 3**\
Uninstall for all systems and all cases\
This means uninstaller for NesPi+, MegaPi, SuperPi and GPi cases\
for RetroPie, RecalBox and BATOCERA
for RetroPie, RecalBox, BATOCERA, and Ubuntu.

## Section 1. RetroFlag Pi-Case+ Safe Shutdown

Expand All @@ -22,7 +22,7 @@ for RetroPie, RecalBox and BATOCERA
#### **Multi Switch Shutdown**
with advanced shutdown features for more natural behaviour:
* If you press restart if emulator is currently running, then you will be kicked back to ES main menu
* If you press restart in ES main screen, ES will be restartet (no reboot!), good for quick saving metadata or internal saves.
* If you press restart in ES main screen, ES will be restarted (no reboot!), good for quick saving metadata or internal saves.
* If you press power-off then Raspberry will shutdown

All metadata is always saved
Expand All @@ -31,14 +31,18 @@ Turn switch "SAFE SHUTDOWN" on PCB to ON.

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

#### Example for **RetroPie:**
#### Example for **RetroPie** and **Ubuntu:**
1. Make sure internet connected.
2. Make sure keyboard connected.
3. Press F4 enter terminal.
3. Press F4 enter terminal (RetroPie only).
4. In the terminal, type the one-line command below (case sensitive):

For RetroPie:\
**`wget -O - "https://raw.githubusercontent.com/crcerror/retroflag-picase/master/install.sh" | sudo bash`**

For Ubuntu:\
**`wget -O - "https://raw.githubusercontent.com/crcerror/retroflag-picase/master/install_ubuntu.sh" | sudo bash`**

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

#### Example for **RecalBox** and **Batocera:**
Expand Down Expand Up @@ -99,7 +103,7 @@ All metadata is always saved

## Section 3. Uninstallers

#### Example for RetroPie
#### Example for RetroPie and Ubuntu
Type in the terminal, type the one-line command below (case sensitive):

**`wget -O - "https://raw.githubusercontent.com/crcerror/retroflag-picase/master/uninstall_all.sh" | sudo bash`**
Expand Down
92 changes: 92 additions & 0 deletions install_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash
# Mod by Dolfies
# This is meant only for Ubuntu (confirmed working on Ubuntu Server 20.10)

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

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

#Step 3) disable UART from retroflag install ---------------
cd /boot/firmware
File=config.txt
if grep -q "^enable_uart=1" "$File";
then
echo "UART is already enabled. Disableing now!"
echo "Commenting out line - your CPU is not throttled anymore"
sed -i -e "s|^enable_uart=1|#enable_uart=1|" "$File" &> /dev/null
else
echo "UART is disabled. CPU is working with full speed"
fi
#-----------------------------------------------------------

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

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

if [ -e $script ];
then
echo "Script SafeShutdown.py already exists. Overwriting file now!"
echo "Downloading ..."
else
echo "Script will be installed now! Downloading ..."
fi

wget -N -q --show-progress "https://raw.githubusercontent.com/crcerror/retroflag-picase/master/SafeShutdown.py"
wget -N -q --show-progress "https://raw.githubusercontent.com/crcerror/retroflag-picase/master/multi_switch.sh"
chmod +x multi_switch.sh

#-----------------------------------------------------------

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

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

chmod +x $RC

#-----------------------------------------------------------

#Step 7) enable overlay file for powercut ---------------
cd /boot/firmware
File=config.txt
if ! grep -q "^dtoverlay=gpio-poweroff,gpiopin=4,active_low=1,input=1" $File; then
echo "Enable overlay file"
echo "# Overlay setup for proper powercut, needed for Retroflag cases" >> "$File"
echo "dtoverlay=gpio-poweroff,gpiopin=4,active_low=1,input=1" >> "$File"
fi

#-----------------------------------------------------------

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