ACPI Wakeup / Shutdown Script Mythtv Frontend & Slaves

This script is pretty straight forward. I wrote it a while back to handle acpi shutdown / wakeup for my slave backends.

I had issues getting mythwelcome and acpi working, so I opted to just create a cronjob that determined when a machine was idle enough to shutdown.

Basically this will check for upcoming recording schedules and set the time ~10 minutes earlier for wakeup. It will also wakeup daily to check for new recordings and then shutdown. If you're using xine or mplayer or watching/recording the host will stay running, anything else and the machine will go to down.

I run this */5 in cron, and there is a 3 minute grace period loop that if the shutdown checks are true, and you haven't yet started to watch another movie or don't have a live preview in "watch recordings" going the machine will go down. This may be a little to strict for some users so play with cron settings to your liking. I prefer my slave backend to go to shortly after I've finished using it.

There are a few settings in the beginning that need to be defined for the host you intend to set this up on namely the following:

If you don't have a tuner on the host just set this number higher than the actual number of tuners you have in use.
This will just trick the scheduler check so that it finds no reason to wake up.

my $hosttuner='2'; #tuner to check for on this slave

This is the hour you want the host to wakeup everyday, even if there is nothing to record. I found this handy so that my slave backends at least wakeup daily to check and see if they need to wakeup again for future recordings. Otherwise you could potentially have a host that wants to shutdown and not wake up for a week or month, etc depending on how busy your schedule is.

my $dailywake='19'; # 2 digit hour for daily wakeup for
slave-backend wakeup.

This is the time you want the host to shutdown if it's not busy recording, commflagging, etc. So if it wakes up and schedules the next time it should wake up (for recording) if certain criteria is met then this is the time the shutdown will occur. (some conditions exist where it will stay awake if less than 1 hour to next recording, etc)

my $dailydown='23'; # Daily shutdown time if the system is idle

This needs to be set to the path that you use for recordings. The script will check to see if files are in use here to determine if the machine is still busy.

my $recordpath='/video/recordings'; #Path where recordings are stored

Hopefully this is useful to someone.
Feedback is appreciated.

Plain text icon KB