#!/bin/bash echo "$(date) $1" >> /storage/WAKE.log if [ "$1" = "post" ] then echo "$(date) $1 rebooting..." >> /storage/WAKE.log /usr/sbin/reboot fi
------------
I have a Zotac zbox running OpenElec (2.99.5 as I write this - I'm waiting patiently for the final version 3). I like to have it go into standby when I'm not using it. So far, so easy: I just set XBMC to issue a suspend instead of shutting down when receiving a power off command from my MCE remote. This is achieved in the XBMC settings menu.
There was a problem with this however. I have my media served to the zbox over NFS. I find NFS to be less CPU intensive on both the zbox and the Linux Mint server which hosts my RAID array.
The problem was that sometimes when the zbox came back out of sleep when instructed to do so by the remote it wouldn't be able to see the NFS shares for some reason and the only way to get it working again was to reboot the zbox. Obviously this did not pass the "wife test". It annoyed her and made her just switch everything off and not bother.
So the first thing I did was to put a small PHP web page on the server which simply SSHed into the zbox and issued a reboot. I made this look OK on an iPhone and added an icon to the wife's iPhone home screen.
"reboot" issues '/sbin/reboot' "restart" issues '/bin/killall -9 xbmc.bin' |
This was still a little untidy, as there were extra steps to get things working.
So instead I looked for a way to reboot the zbox when it was woken from sleep.
There is a way. It turns out that OpenElec (or XBMC, not sure which) automatically executes any script with the extension .power found in the directory /storage/.xbmc/addons/_server/sleep.d/
I put a script called wake.power in there which looks like this:
#!/bin/bash echo "$(date) $1" >> /storage/WAKE.log if [ "$1" = "resume" ] then echo "$(date) $1 rebooting..." >> /storage/WAKE.log /sbin/reboot fiAnd, hey-presto! When the zbox is woken from sleep it reboots, making it look like it has actually just been powered on. This works well because OpenElec only takes a few seconds to display the interface after a reboot.