View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 4 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Wed May 23, 2007 1:25 pm 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
In the past I've been burned by forgetting to check what activity is going on in my boxen before rebooting. I was tired of ending up with split show that missed a few minutes. I modified the mythfilldatabase script from imstr8trippin to suit my needs and I thought I would share the script
Code:
#!/bin/sh

# initalize variables
db='mythconverg'

# substitute the username you want to you use to connect to mySQL
user='root'

# password variable is here, but I haven't used it
password=''

# run SQL
data0=`mysql $db -u $user -e "select count(*) from inuseprograms where recusage like 'player'" -sN`
data1=`mysql $db -u $user -e "select count(*) from inuseprograms where recusage like 'recorder'" -sN`
data2=`mysql $db -u $user -e "select count(*) from record \
        where inactive=0 and (type!=0 or type!=8) and \
        timediff(sysdate(),concat(startdate,' ',starttime))<'00:10:00' and \
        timediff(concat(startdate,' ',starttime),sysdate())<'00:10:00';\
        " -sN`

if [ $data0 -ge 1 -o $data1 -ge 1 -o $data2 -ge 1 ]; then
        echo -e "\033[31m\n         WARNING!!!\033[0m\n"
        if [ $data0 -ge 1 ]; then
                echo "MythTV is watching $data0 program(s)"
        fi
        if [ $data1 -ge 1 ]; then
                echo "MythTV is recording $data1 program(s)"
        fi
        if [ $data2 -ge 1 ]; then
                echo "MythTV has scheduled $data2 program(s) within 10 minutes"
        fi
        echo -e "\nDo you still wish to reboot? (y/n)"
        read ANSW
        case $ANSW in
         y) reboot ;;
         *) exit 0
        esac
else
        echo "Rebooting"
        reboot
fi

exit 0

I've also created an alias for this to the reboot command to idiot-proof rebooting against myself

Edit: Prettied it up

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Last edited by Gnarl on Thu May 24, 2007 12:23 pm, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 11:21 am 
Offline
Joined: Thu Mar 16, 2006 1:00 pm
Posts: 87
You are amazing! I cant' count the number of times I've done the exact same thing. Thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 4:23 pm 
Offline
Joined: Fri May 21, 2004 11:55 pm
Posts: 1206
Location: Silicon Valley, CA
Looks very cool! Does this go in place of the KnoppMyth shutdown script that is called from the UI?

_________________
Do you code to live, or live to code?
Search LinHES forum through Google


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 5:27 pm 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
Command line use only for now. You can't answer the prompt from within the frontend

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Top
 Profile  
 

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


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 1 guest


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