Intro
This page describes the steps needed to get
ACPI Wakeup running in conjunction with
Mythwelcome on your KM R5.5 box. Together they will automatically boot your machine prior to a scheduled recording and then shutdown your machine when not in use after a specified time thus saving power and insuring you never miss a show. This of course assumes RTC wakeup alarms are supported in the BIOS of your motherboard. You'll be hard pressed to find a modern motherboard that doesn't support this option. I'm using an old A7N8X-VM that's from 2003 and it works on it.
Using Mythwelcome
As I mentioned, the scripts that drive the shutdown/startup work in conjunction with Mythwelcome which maybe unfamiliar to some users. Here is my nickel tour of mythwelcome:
As you can see, mythwelcome shows lots of relevent info including, the current date/time, the current status of the box (idle, recording, flagging commericial, transcoding, etc.), the next scheduled recording, and when it will occur, and in this case a countdown until it shuts the machine off. It also lets you know if there are any conflicts (although this isn't depicted in the screenshot above), and may display additional info that I haven't seen too.
Aside from starting the frontend like the only button shows, you can also hit the menu button (the M key on the keyboard) if you want to lock the auto shutdown featyre so that the box is up indefinitely (or at least until you unlock it), manually force a mythfilldatabase, manually force a shutdown, or simply exit to the KM desktop.
To me, that lock feature is little redundant since all you need to do is leave your frontend running and none of the auto shutdown stuff will happen -- remember
auto shutdown only happens when mythwelcome is running. Therefore, when you're ready to power down the box, simply exit out to mythwelcome it'll shut the machine down assuming:
1) No shows are queued to record in the time you specify (read on for this setting).
2) The count down timer reaches 0 (again you specify an idle time to shutdown).
3) No frontend boxes are connected.
4) No jobs are in progress (commercial flagging, transcoding, etc.).
More importantly, it will automatically power on your machine before a queued program is due to record (you specify how far in advance it waits to turn on).
As #3 above states, mythwelcome is smart enough to know if other frontend machines on your network are hitting the backend server; in this case, it will not shutdown unless the frontend machine(s) is finished using the backend (i.e. you shut it down or exit mythfront-end on that machine). If you leave a frontend connected and idle, the mythwelcome will NOT shut the backend machine down.
Credit Where Credit is Due
Nearly all the content below came from
this wiki page. A little bit came from
mythtv.org wiki too. I know that some people like to see highly detailed writeups with screenshots and as some of you know, writing these sorts of documents "HOWTOs" is my way of giving back to the KM community.
Testing ACPI Wakeup Before Modifying Your KM Box
Assuming you have a functional KM install (guide was written and tested with R5.5), test your computer's ability to boot without modifiying anything with one exception. Cesman recently posted the following in tjc's
R5.5 Hints:
cesman wrote:
Slight boobery on my part...
Code:
update-rc.d acpid start 12 2 3 4 5 . stop 88 0 1 6 .
Do this as root and acpid will work. If your BIOS/motherboard supports it, when you press the power button, the system will work off appropriately.
Prior to executing that, my PC would not wakeup. Therefore, go ahead and do it.
Code:
# update-rc.d acpid start 12 2 3 4 5 . stop 88 0 1 6 .
Then test the mythwelcome wakeup on your machine:
Code:
$ mythwelcome-test-wakeup.sh
Which should return:
Code:
Computer set to start in 4 minutes
Execute the following command
shutdown -h now
Now manually issues the shutdown command it instructed you to do and wait the 4 minutes.
Code:
$ sudo shutdown -h now
If the box doesn't turn on automatically, there are a number of reasons why it might not work. Have a look at both of the wiki pages I mentioned in the top of the post (particularly the mythtv.org wiki page, in a section entitled, "Fussy BIOS.")
If it continues to fail depsite your efforts, your hardware might not support this and you can consider using the alternative nvram-wakeup method described on
this wiki page.
Enable MythwelcomeAfter you complete these steps, your box will boot to
Mythwelcome. From there you can start the frontend. For the ACPI wakeup to work, you must exit your frontend and allow mythwelcome to handle everything including manually shutting down your box. If you manually enter a shutdown command, or shutdown the box from the frontend menu, you risk the machine not booting automatically (this depends on whether or not your recording schedule has changed since the last time the shutdown scripts ran).
To setup mythwelcome, simply modify your .fluxbox/apps so that mythwelcome starts:
Code:
$ nano /home/mythtv/.fluxbox/apps
Comment out the current line that reads "[startup] {mythfrontend}" simply by putting a number sign (#) in front of it. Now under that line, type the following, "[startup] {mythwelcome}" and save the file (ctrl-x).
Here is what that section in mine looks like for your reference:
Code:
#[startup] {mythfrontend}
[startup] {mythwelcome}
Now we'll configure mythwelcome via this command:
Code:
$ mythwelcome --setup
Make the following changes so it looks like this and then exit:
Code:
Command to Set Wakeup Time: /usr/local/bin/mythwelcome-set-alarm.sh --settime $time
Wakeup Time Format: time_t
nvram-wakeup Restart Command: <<<LEAVE IT BLANK>>>
Command to reboot: /sbin/reboot
Command to shutdown: /sbin/poweroff
Command to run Xterm: xterm
Command to start the Frontend: /usr/bin/mythfrontend
For reference, you'll find the default R5.5 values at the end of this post in case you want to revert to them.
Reconfigure Mythtv to use MythWelcomeFirst exit your frontend, stop your backend, and run mythtv-setup:
Code:
# /etc/init.d/mythtv-backend stop
$ mythtv-setup
Now to go General>5th page and configure as follows:
Code:
Wakeup time format: yyyy-MM-dd:hh:mm
Command to set Wakeup Time: /usr/bin/mythshutdown --setwakeup $time
Server Halt Command: sudo /usr/bin/mythshutdown --shutdown
Pre-shutdown Check Command: /usr/bin/mythshutdown --check
Blank out your Startup command.
I recommend that you leave the checkbox for "Block shutdown before client connected" UNCHECKED. If you check it, and your box automatically boots up, it WILL NOT shutdown until you start the frontend. This can be a pain if you're on vacation or away from your home for several days as the box will stay up. Just know that you should give the Idle time before shutdown setting a larger number in case you boot the box, then get distracted and are unable to enter the frontend before it shutsdown.
The next three settings can be whatever you like. These are just what I'm using. Consider your startup before record time carefully if you haven't modified your file system on your /myth partition. Every 30 times your system boots, a disk check is forced via fsck. Depending on the size of your drive, this can take a while. Before I switched my /myth to XFS, this check took 15-20 minutes on my 500 gig partition. Take this into account when selecting a wake up time, you might lose the first 5-20 minutes of your program!
What's XFS you ask? See these threads:
XFS: How and Why - Create an XFS partitionHow to Defragment XFS Partitions and Keep Them That WayXFS Maintenance - Read if You're New to XFS (teaches you how to use xfs_repair which is like fsck for XFS)Again, for your reference, you'll find the default R5.5 values at the end of this post in case you want to revert to them. Save the settings and exit mythtv-setup.
Restart the backend and restart X to insure that mythwelcome starts using this command:
Code:
# /etc/init.d/myth-backend start
$ pkill xinit
If everything worked right, your machine should have restarted X and you should see Mythwelcome.
That's it, enjoy!
Appendix
As promised here are the out-of-the-box settings: