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: Sat Mar 10, 2007 3:11 pm 
Offline
Joined: Sat Sep 02, 2006 1:46 pm
Posts: 44
Maybe this is overkill, but I thought I would post this. Maybe someone might find this useful. Since I am currently using the ACPI wakeup feature and don't have have my box on all the time, I could not run mythfilldatabase at the time suggested by the zap2it server. I know that you can manually set a specific time to run, but I thought it would be nice to have my box figure out when it needed to wake up to run mythfilldatabase at the suggested time. I created a script to run mythfilldatabase and then set a daily wakeup period in mythwelcome to turn on around the suggested time. I now just point to this script rather than mythfilldatabase (you set that on one of the "General" settings pages). I just completed one cycle through the whole timeline and it seems to be working. The part I have not tested completely is the code that adjusts the time so that the period does not cross midnight. Feel free to offer any suggestions or point out any flaws I overlooked.

Code:
#!/bin/bash

mythfilldatabase --quiet

window=5
fill_str="MythFillSuggestedRunTime"
start_str="DailyWakeupStartPeriod1"
end_str="DailyWakeupEndPeriod1"
mysql_cmd="mysql -u mythtv -pmythtv mythconverg"
get_settab="SELECT value,data FROM settings"

dbfilltime=$($mysql_cmd -e"$get_settab" | /bin/grep $fill_str | /bin/sed -e"s/^$fill_str\t//" -e"s/T/ /" );
runtime=$(/bin/date -d "$dbfilltime" +%s);

# This stuff adjusts the suggested time because Mythwelcome currently
# does not accept wake up periods that cross midnight
suggesttime=$(/bin/date -d "$dbfilltime" +%H%M);
if [ $suggesttime -ge $[2360-$window] ]; then
    runtime=$[runtime-$window*60]
    newtime=$(/bin/date -d "1970-01-01 UTC $runtime sec" +%FT%T);
    set_fill="UPDATE settings SET data='$newtime' WHERE value='$fill_str'"
    $mysql_cmd -e"$set_fill"
elif [ $suggesttime -le $window ]; then
    runtime=$[runtime+$window*60]
    newtime=$(/bin/date -d "1970-01-01 UTC $runtime sec" +%FT%T);
    set_fill="UPDATE settings SET data='$newtime' WHERE value='$fill_str'"
    $mysql_cmd -e"$set_fill"
fi

start1=$(/bin/date -d "1970-01-01 UTC $[runtime-$window*60] sec" +%H:%M);
stop1=$(/bin/date -d "1970-01-01 UTC $[runtime+$window*60] sec" +%H:%M);

set_start="UPDATE settings SET data='$start1' WHERE value='$start_str'"
set_end="UPDATE settings SET data='$stop1' WHERE value='$end_str'"
$mysql_cmd -e"$set_start"
$mysql_cmd -e"$set_end"



BTW, this only works if you enable the "Auto-Start Front End" in mythwelcome and you disable the "Block Shutdown Before Client Connects" in mythtv-setup (General options).


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 19 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