View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 1 post ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Sun Sep 24, 2006 3:41 am 
Offline
Joined: Mon Feb 06, 2006 5:11 pm
Posts: 353
Location: Brisbane, Australia
Hi All,

I didn't like the current wakeup test (knoppmyth-wakeuptest.pl) at the KnoppMythWiki as it didn't take into account the user wakeup periods for performing system tasks etc. I wrote some dodgy code that checks the values stored by NVRAM_WAKEUP and if it is within 10 minutes of the current time then an automated powerup must have been performed.

The routine looks for particular paterns returned by NVRAM_WAKEUP to gather day, hour, minutes and converts everything to minutes since the start of the month, accordingly it will not perform to well at the roll over time at midnight at the end of the month.

PS.
To everyone who has contributed to Knoppmyth and Mythtv, Thank you.

Code:
#!/bin/bash
#Alternative method for checking reason for powerup.
#Checks values stored in NVRAM_WAKEUP and if within 10 minutes,
#then must be due to automated processes.

#DESIGN LIMITATION
#Doesn't handle time period around midnight of last night of month

#Enjoy
#BigB

#Get time stored in NVRAM
NVRAM_DAY="`sudo nvram-wakeup |awk '$1=="Day" { print $3 }'`"
NVRAM_HOUR="`sudo nvram-wakeup |awk '$1=="rtcHour" { print $3 }'`"
NVRAM_MIN="`sudo nvram-wakeup |awk '$1=="rtcMin" { print $3 }'`"

#echo "$NVRAM_DAY $NVRAM_HOUR $NVRAM_MIN"

let "NVRAM_TIME = NVRAM_DAY*24*60 + NVRAM_HOUR*60 + NVRAM_MIN"

#Get current date (remove '-u' option for non utc time)
DATE="`date -u +%e%t%H%t%M`"

#parse Date
NOW_DAY="`echo $DATE|awk '{ print $1 }'`"
NOW_HOUR="`echo $DATE|awk '{ print $2 }'`"
NOW_MIN="`echo $DATE|awk '{ print $3 }'`"

#echo "$NOW_DAY $NOW_HOUR $NOW_MIN"

let "NOW_TIME = NOW_DAY*24*60 + NOW_HOUR*60 + NOW_MIN"
#Time 10 minuts ago
let "THEN_TIME = NOW_TIME - 10"


if [ "$NVRAM_TIME" -ge "$THEN_TIME" ]; then
   if [ "$NVRAM_TIME" -le "$NOW_TIME" ]; then
     echo "Automated wakeup, killing Mythfrontend"
     sleep 30
     killall mythfrontend
   else
     echo "Automated wakeup is in future"
   fi
else
  echo "Automated wakeup in in past"
fi


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu