[mythtv-users] [SPAM?]: Re: questions about suspend with ACPI

Leighton Brough brough at baremetalsoft.com
Thu Jun 15 12:42:06 UTC 2006


> If you could post your scripts, that would be very helpful. 
>
>   
This is the script which is used by MythTV, run as the MythTV user to 
enter S3:

----------------------
#!/bin/bash

#
# This script provides a mythtv specific wrapper
# to the system S3 script.
#
# It adds functionality to start and stop the
# mythtv specific processes.
#

#
# Stop mythtv front and back ends
#
echo Stopping mythtv
pkill mythfrontend
pkill mythbackend
pkill mythwelcome
pkill irxevent
pkill irexec

#
# Do the deed
#
sudo /root/S3 2>&1 > /var/log/mythtv/S3.log

#
# Restart the mythtv related processes
#
./start-irexec
./start-irxevent
./start-mythbackend
----------------------

This calls the following script, which is run as root via sudo:

----------------------
#!/bin/bash

#
# Stop lirc, acpid and hotplug
#
echo Stopping daemons
/etc/init.d/hotplug stop
/etc/init.d/lircd stop
/etc/init.d/acpid stop

#
# Remove modules that can't cope with S3
#
echo Removing modules
rmmod dvb_bt8xx dst_ca dst bt878 bttv
rmmod ehci_hcd
rmmod uhci_hcd
rmmod lirc_mceusb2

#
# Unmount samba shares from monaro
#
umount /mnt/music
umount /mnt/photos

#
# Setup USB1 to wakeup
#
#echo USB1 > /proc/acpi/wakeup

#
# Sync to keep disks clean
#
echo Disk sync
sync

#
# Change to mode ACPI S3
#
date
echo Going into S3 now
echo -n mem > /sys/power/state

#
# Back from S3 now...
#
echo Back from S3 now

#
# Update the system clock from the hardware clock
#
hwclock --localtime --hctosys
date

#
# Mount samba shares
#
mount /mnt/music &
mount /mnt/photos &

#
# Reload the modules that needed to be stopped
#
echo Restarting modules
modprobe lirc_mceusb2
modprobe uhci_hcd
modprobe ehci_hcd
modprobe bttv
modprobe bt878
modprobe dst
modprobe dst_ca
modprobe dvb_bt8xx

#
# Restart acpid and hotplug
#
echo Restarting daemons
/etc/init.d/hotplug start
/etc/init.d/lircd start
/etc/init.d/acpid start
----------------------

This is the script that MythTV uses to set the wakeup time. This deals 
with converting the parameters from the format used by nvram-wakeup to 
those needed by /proc/acpi/wakeup:

----------------------
#!/usr/bin/perl

#
# This script is invoked by mythshutdown to set the wakeup time.
# mythshutdown thinks it's calling nvram-wakeup, and it passes
# "--settime" and a single integer on the command line, which is the
# startup UTC time in seconds since the epoch. We convert it to the form
# understood by the system wakeup script.
#
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = 
localtime ($ARGV[1]);
$year += 1900;
$mon += 1;
$wakeup_time = sprintf "%4.4u-%2.2u-%2.2u %2.2u:%2.2u:%2.2u", $year, 
$mon, $day, $hour, $min, $sec;
`sudo /root/wakeupat "$wakeup_time"`;
----------------------

This in turn calls the following script which runs as root to do the deed:

----------------------
#!/bin/bash
echo $1 > /tmp/wakeupat
echo $1 > /proc/acpi/alarm
----------------------




More information about the mythtv-users mailing list