As promised here is a step-by-step tutorial on how to make the power button on the i-Sabre V3 work with Moode.
If you mess up anything it is not my responsibility. Read all the appropriate stuff about Linux before you begin.
All this is done in a SSH session to your Pi.
In Terminal (Mac) or PuTTY (PC) or equivalent type
You will be asked for a password. That is ‘raspberry’ (without the quotes).
1/ Installation of WiringPi:
You’ll need WiringPi to communicate withe the GPIO pins on the Pi.
To do so you’ll need to install gcc:
and:
now on to wiringPi:
Code : Tout sélectionner
cd /home/pi
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
If all goes well you can now get an overview of the GPIO pins by typing
2 / Creating the script for the command from the power button:
The script to make the LED stop blinking after startup is on Github.
First we need to go back to /home/pi
Then we can get the script
Code : Tout sélectionner
wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/sds.sh
3 / Add the script button at startup: Editing the startup file:
Now edit rc.local. This will make the script run at startup. I use nano, you’ll find manuals all over the web:
Add this line before "exit 0”. Don’t delete or change anything else in this file, just add the extra line.
4 / Creating command scripts for Moode restart and shutdown:
softshutdown recovery script:
Code : Tout sélectionner
sudo wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/softshutdown.sh
softreboot recovery script:
Code : Tout sélectionner
sudo wget https://raw.githubusercontent.com/audiophonics/Raspberry-pwr-management/master/softreboot.sh
I don’t know if the scripts need to be executable, but I don’t think it can hurt to do so:
Code : Tout sélectionner
sudo chmod +x sds.sh
sudo chmod +x softshutdown.sh
sudo chmod +x softreboot.sh
5 / Make Moode work with the scripts.
First make a backup of the original worker.php file in case you mess things up:
We can now edit the original:
Search for ‘reboot’ until you find the part that reads this:
Code : Tout sélectionner
case 'reboot':
sysCmd('mpc stop');
sysCmd('systemctl stop nginx');
sysCmd('reboot');
break;
case 'poweroff':
sysCmd('mpc stop');
sysCmd('systemctl stop nginx');
sysCmd('poweroff');
break;
Here we will replace the reboot and poweroff commands with the scripts that now reside in /home/pi.
Change the text so it reads:
Code : Tout sélectionner
case 'reboot':
sysCmd('mpc stop');
sysCmd('systemctl stop nginx');
sysCmd('sudo bash /home/pi/softreboot.sh');
break;
case 'poweroff':
sysCmd('mpc stop');
sysCmd('systemctl stop nginx');
sysCmd('sudo bash /home/pi/softshutdown.sh');
break;
Reboot the Pi and if all goes well your LED should stop blinking and you should be able to power down with the button as well as through the Moode web-interface. The developer of Moode promised to look into changing worker.php so it will always call a shutdown/reboot script. Once that is in place, this tutorial is obsolete. I did this on version 2.6 and did not update since.
Enjoy,
Arjen