JaseP,
Thanks for the pointer. I'm not looking for that so much as for the usual kids leaving it on, or the auto-wake when the router reloads.
I'm using MiniMyth right now, and use a script to shutdown a slave backend when it's sitting on the MythWelcome screen. I'd planned to expand it to look at how long the screensaver was running for, but haven't gotten around to it yet.
For anyone who's interested, here's the script...
#!/bin/bash
#
# Script to safely shutdown slave backend
# Minimum uptime in minutes to avoid shutting down prematurely.
MIN_UPTIME=20
#SHUTDOWNCMD="su -c /usr/bin/mm_sleep root"
SHUTDOWNCMD="/sbin/poweroff"
date
UPTIME=`uptime |cut -f4 -d" "`
UPTIME_UNITS=`uptime |cut -f5 -d" " |tr -d ','`
echo "Uptime:" $UPTIME $UPTIME_UNITS
if [[ $UPTIME_UNITS == "min" ]] && [[ $UPTIME -lt $MIN_UPTIME ]]
then
echo "Uptime less than minimum uptime:" $MIN_UPTIME
exit 1
fi
# Check if mythfrontend is running, exit if true
if ps -C mythfrontend | grep mythfrontend -c
then
echo "Mythfrontend running, shutdown aborted"
exit 1
fi
mythshutdown -s
STATUS=$?
echo "MythStatus code:" $STATUS
# 0 - Idle
# 1 - Transcoding
# 2 - Commercial Flagging
# 4 - Grabbing EPG data
# 8 - Recording - only valid if flag is 1
# 16 - Locked
# 32 - Jobs running or pending
# 64 - In a daily wakeup/shutdown period
# 128 - Less than 15 minutes to next wakeup period
# 255 - Setup is running
case "$STATUS" in
0)
echo "Myth is idle, shutting down now"
mythshutdown --setscheduledwakeup
su -c 'rm /etc/rc.d/rc/K60modules_automatic' root
mm_service backend stop
`$SHUTDOWNCMD`
;;
8|40)
echo "Myth is busy recording"
exit 1
;;
16)
echo "Myth is locked, aborting shutdown"
exit 1
;;
32|33|34|35)
echo "Jobs running"
# Check if mythcommflag is running locally, exit if true
if ps -C mythcommflag | grep mythcommflag -c
then
echo "Mythcommflag running, shutdown aborted"
exit 1
fi
# Check if mythtranscode is running locally, exit if true
if ps -C mythtranscode | grep mythtranscode -c
then
echo "Mythtranscode running, shutdown aborted"
exit 1
fi
# This backend isn't busy with jobs, so shutdown
echo "This backend is idle, shutting down now"
mythshutdown --setscheduledwakeup
su -c 'rm /etc/rc.d/rc/K60modules_automatic' root
mm_service backend stop
`$SHUTDOWNCMD`
;;
64|128)
echo "Awake on purpose"
exit 1
;;
*)
echo "Busy with unknown tasks, presume this backend is busy"
exit 1
;;
esac
Hope that helps fuel someone's creativity should they get around to this before I do (which is more than likely as my course runs till mid May)
/Mike