Shutdown scripts for RuneAudio
The default SSH user name is root, password rune
- Key in :
- cd /etc
- nano irswitch.sh
-
Copy and paste (use shift+ins to paste in nano) the following text into the editor window
#!/bin/bash
# this is the GPIO pin receiving the shut-down signal
GPIOpin1=14
echo "$GPIOpin1" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
while true; do
sleep 1
power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
if [ $power != 0 ]; then
mpc stop
/srv/http/command/rune_shutdown
echo "out" > /sys/class/gpio/gpio$GPIOpin1/direction
echo "1" > /sys/class/gpio/gpio$GPIOpin1/value
sleep 3
poweroff
fi
done - Press ctrl+x to exit, y to confirm, enter to save the file
-
Key in
chmod +x irswitch.sh
- RuneAudio is based on Arch Linux, in order to run the above script at boot it has to be registered as a startup service :
- Key in
cd /usr/lib/systemd/system
nano irswitch.service - Copy and paste the following text into the editor window
[Unit]
Description=RemotePi Service
After=systemd-modules-load.service
[Service]
Type=simple
ExecStart=/etc/irswitch.sh
[Install]
WantedBy=multi-user.target - Press ctrl+x to exit, y to confirm, enter to save the file
- Key in
systemctl enable irswitch.service
The following additional script enables the RemotePi Board to cut off the power, after RuneAudio has been shut down from the on-screen menu.
- Key in
- sudo nano /etc/shutdown.sh
- Copy and paste the following contents
-
#!/bin/bash
GPIOpin=15
echo "$GPIOpin" > /sys/class/gpio/export
# execute shutdown sequence on pin
echo "out" > /sys/class/gpio/gpio$GPIOpin/direction
echo "1" > /sys/class/gpio/gpio$GPIOpin/value
sleep 0.125
echo "0" > /sys/class/gpio/gpio$GPIOpin/value
sleep 0.2
echo "1" > /sys/class/gpio/gpio$GPIOpin/value
sleep 0.4
echo "0" > /sys/class/gpio/gpio$GPIOpin/value - Press ctrl+x to exit, y to confirm, enter to save the file
- Mark ir as executable by keying in
chmod +x /etc/shutdown.sh - Edit the file rune_SY_wrk located in /var/www/command/ with
nano /var/www/command/rune_SY_wrk - Find at or near line 600 the text sysCmdAsync(‘poweroff'); and change it to sysCmdAsync(‘/etc/shutdown.sh’);
- Reboot one time
-
After the reboot you can use the RemotePi Board to power cycle RuneAudio.
(thanks to Guy B. from the UK for the RuneAudio shutdown by script)
The above scripts have been tested and are confirmed to work up to RuneAudio 0.4-beta. Although not yet tested, they most likely will work with newer versions as well.
This page was last updated 21-Apr-2018