MythTV

From Blue-IT.org Wiki

Revision as of 12:37, 3 October 2010 by Apos (talk | contribs) (Created page with "== Shutdown check == #!/bin/bash # # MythShutdownCheck # # checks to see if any other user is # logged in before idle shutdown # # returns "1" if yes, stopping shutdown...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Shutdown check

#!/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 | 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?
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