Skip to content

Instantly share code, notes, and snippets.

@alanbchristie
Last active July 9, 2024 06:37
Show Gist options
  • Save alanbchristie/a421cb9568ac9611436e16dee75e589b to your computer and use it in GitHub Desktop.
Save alanbchristie/a421cb9568ac9611436e16dee75e589b to your computer and use it in GitHub Desktop.
Adventures with the PiStation Safe Shutdown feature
# The PiStation Case (for the Raspberry Pi 4)
# is a well built fun case, especially for those
# with a passion for retro-gaming consoles.
# Personally, I love it.
#
# - https://shop.pimoroni.com/products/pistation-case
#
# But installing the 'safe shutdown' feature may get you frustrated.
# The hardware's brilliant, but the shutdown script installation
# needs a little work. There are a number of
# issues the current installation script does not resolve: -
#
# - Needs Python and the RPi GPIO module (I use Python 3)
# - Coping with the lack of /etc/rc.local script
# - Broken shutdown behaviour
#
# I'm using an 8GiB RPi 4 Running a 64-bit Ubuntu (21.04).
# The SafeShutdown feature works, but this is what I had to do
# to get it to _actually_ work...
# 1. Get the shutdown script yourself
SourcePath=https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master
script=/opt/RetroFlag/SafeShutdown.py
wget -O $script "$SourcePath/SafeShutdown.py"
# 2. Install pip3 and the RPi.gpio module
# (I already had python 3)
sudo apt-get update
sudo apt install python3-pip python3-rpi.gpio
# 3. Create your own rc.local
# My ubuntu had no /etc/rc.local
# This caused the script installation to fail anyway (it expects the file to exist)
# So I just created it by hand with the following content
#
# sudo python3 /opt/RetroFlag/SafeShutdown.py &
sudo vi /etc/rc.local
[...]
sudo chmod +x /etc/rc.local
# 4. Fix the shutdown script
# The shutdown button reboots the Pi, it doesn't shut it down!
#
# See https://github.com/RetroFlag/retroflag-picase/issues/125
#
# Also, consider removing the calls to 'sudo sleep 5s'
# in the reset and shutdown handlers in the script.
# It just adds 5 seconds to the process - do you need that?
# 5. Reboot (to install the shutdown script for the next boot)
sudo shutdown -r now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment