My Raspberry Pi hifi component setup lacked a way to cleanly shutdown the system without ssh.
I wished the Raspberry Pi had a button so I can tell it to shutdown.
I added one to the GPIO connector.
It turns out many wishes can come true when one has a GPIO board.
This is the /usr/local/bin/stereo-gpio
script that reacts to the button press
and triggers a shutdown:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
This is the /etc/systemd/system/stereo-gpio.service
systemd unit file that
runs the script as a daemon:
[Unit]
Description=Stereo GPIO manager
[Service]
Type=simple
ExecStart=/usr/local/bin/stereo-gpio
Restart=always
[Install]
WantedBy=multi-user.target
Then
systemctl start stereo-gpio
to start the script, and
systemctl enable stereo-gpio
to start the script at boot.