Difference between revisions of "MythTV"

From Blue-IT.org Wiki

(Check for shutdown)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
== Blog article (German) ==
 +
[http://www.justmy2cents.blue-it.org/fernsehen-musik-und-videos-aus-einer-box-mythtv Fernsehen, Musik und Videos aus einer Box]
 +
 +
== Ports ==
 +
netstat -lnvp | grep myth
 +
tcp        0      0 192.168.178.23:6543    0.0.0.0:*              LISTEN      2858/mythbackend
 +
tcp        0      0 127.0.0.1:6543          0.0.0.0:*              LISTEN      2858/mythbackend
 +
tcp        0      0 192.168.178.23:6544    0.0.0.0:*              LISTEN      2858/mythbackend
 +
tcp        0      0 127.0.0.1:6544          0.0.0.0:*              LISTEN      2858/mythbackend
 +
tcp6      0      0 ::1:6543                :::*                    LISTEN      2858/mythbackend
 +
tcp6      0      0 ::1:6544                :::*                    LISTEN      2858/mythbackend
 +
 
== Cron ==
 
== Cron ==
 
  0,15,30,45 * * * *      mythtv  /home/mythtv/tvm2vdr/tvm2xml_auto.sh
 
  0,15,30,45 * * * *      mythtv  /home/mythtv/tvm2vdr/tvm2xml_auto.sh
Line 33: Line 45:
  
  
== Shutdown check ==  
+
== Mythtv shutdown check script==
 +
As my mythtv box is not only for using mythtv, but also for browsing in the internet, playing music via rhythmbox, I also have to check, if these programs are actually running or not.
 +
It also checks for ANY logged in Users EXCEPT the one using the actual mythtv box ('':0''). So if you are logged in, and don't use any of the listed programs, the box will shutdown.
  
 
  #!/bin/bash
 
  #!/bin/bash
Line 59: Line 73:
 
  echo ... checking users logged in.
 
  echo ... checking users logged in.
 
   
 
   
#if last | head | grep -q "tty/.*still logged in"  # check for active *remote* login?
 
#if last | grep still | grep :0 # check for active *graphical* login?
 
#if false  # FOR TESTING ONLY WHEN LOGGED IN
 
 
  if last | grep still | grep -v ":0" # check for active *ANY* login?
 
  if last | grep still | grep -v ":0" # check for active *ANY* login?
 
  then
 
  then
Line 106: Line 117:
 
   
 
   
 
  fi
 
  fi
 +
 +
[[Category:Ubuntu]]
 +
[[Category:MythTV]]

Latest revision as of 21:14, 23 July 2012

Blog article (German)

Fernsehen, Musik und Videos aus einer Box

Ports

netstat -lnvp | grep myth tcp 0 0 192.168.178.23:6543 0.0.0.0:* LISTEN 2858/mythbackend tcp 0 0 127.0.0.1:6543 0.0.0.0:* LISTEN 2858/mythbackend tcp 0 0 192.168.178.23:6544 0.0.0.0:* LISTEN 2858/mythbackend tcp 0 0 127.0.0.1:6544 0.0.0.0:* LISTEN 2858/mythbackend tcp6 0 0 ::1:6543  :::* LISTEN 2858/mythbackend tcp6 0 0 ::1:6544  :::* LISTEN 2858/mythbackend

Cron

0,15,30,45 * * * *      mythtv  /home/mythtv/tvm2vdr/tvm2xml_auto.sh
5,20,35,50 * * * *      mythtv  /home/mythtv/tvm2vdr/mythfilldatabase_auto.sh
0,5,10,15,20,25,30,35,40,45,50,55 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23    * * *   root  /bin/bash /root/bin/set_wakeuptime_via_mythshutdown.sh

Setting the acpi wakeuptime manually via script

There are problems with setting the wakeuptime of my pc via the buildin mythtv functionality. I really don't know why. If set the wakeuptime manually in acpi, it works. So I made this script, which runs every five minutes (see Cron):

It comes in two parts

set_wakeuptime_via_mythshutdown.sh

Extracts the string for the next wakeuptime out of the mythshutdown command:

#!/bin/bash
echo "MYTH WAKEUP ----------------------------------"
SHUTDOWN="$(mythshutdown -t -v timestamp | grep "wakeup time given" | cut -d " " -f 8 | sed -e 's/T/ /')"
echo $SHUTDOWN

/root/bin/set_wakeuptime.sh "$(date --date "${SHUTDOWN}" '+%s')"

echo "RTC ----------------------------------"
cat /proc/driver/rtc

echo "WAKEALARM ----------------------------------"
cat /sys/class/rtc/rtc0/wakealarm

set_wakeuptime.sh

#!/bin/bash
#$1 is the first argument to the script. It is the time in seconds since 1970
#this is defined in mythtv-setup with the time_t argument

echo 0 > /sys/class/rtc/rtc0/wakealarm      #this clears your alarm.
echo "$1" > /sys/class/rtc/rtc0/wakealarm     #this writes your alarm.
echo "$(cat /proc/driver/rtc)"


Mythtv shutdown check script

As my mythtv box is not only for using mythtv, but also for browsing in the internet, playing music via rhythmbox, I also have to check, if these programs are actually running or not. It also checks for ANY logged in Users EXCEPT the one using the actual mythtv box (:0). So if you are logged in, and don't use any of the listed programs, the box will shutdown.

#!/bin/bash
#
# MythShutdownCheck
#
# checks to see if any other user is
# logged in before idle shutdown
#
# returns "1" if yes, stopping shutdown
# returns "0" if ok to shutdown
#

reset() {
    echo Resetting mythtv shutdown timer. Going on ...
    exit 1
}

ready() {
    echo System ready for shutdown.
    exit 0
}

echo This is script $0.
echo ... checking users logged in.

if last | grep still | grep -v ":0" # check for active *ANY* login?
then
    echo ... some users are logged in ... continuing.
    reset

else
    echo ... checking for tv_grab_de_prisma process
    if ps x -u mythtv |	grep -v grep | grep tvm2xml_auto.sh
    then
	echo tvm2xml_auto process is still running ... continuing.
	reset

    else
	if ps xa | grep -v grep  | grep /root/bin/rsync_vserver.sh
	then
	    echo vserver backup is running ... continuing.
	    reset

	else
		if ps xa | grep -v grep | grep rhythmbox			
		then
			echo rhythmbox is running ... continuing.
			reset
		else
			if ps xa | grep -v grep  | grep firefox-bin
			then
				echo firefox ist running ... continuing.
				reset
			else
				if [ "$(cat status | grep status | cut -d"=" -f2)" == "stopped" ]
				then 
					echo radio applet is running ... continuing.
					reset
				else
	    				## READY FOR SHUTDOWN ######
        	    			ready
			    		############################
				fi
			fi
		fi
	fi
    fi

fi