Saturday, July 3, 2010

Prevent mythtv from shutting down while you are connected to it

This is a simple python script I use to prevent my mythtv backend to stop when I'm connected to it with samba, http, ssh or other streaming systems...

Just replace 192.168.0.3 or 192.168.0 with the ip numbers from your mythtv backend.
#!/usr/bin/env python
# coding: utf-8

import commands
import sys

res = commands.getoutput('netstat | grep ESTABLISHED | grep -v -e .*192.168.0.3.*192.168.0.3.* -e .*192.168.0.3.*192.168.0.:microsoft-ds.*')
if len(res) > 10:
    sys.exit(1)
sys.exit(0)
 I know that it is possible to use only shell script without python to do that, but I do not master shell script so feel free to modify it to use only shell.

Use this script as the command to launch before shutting down mythtv backend to verify that it can really shutdown.

No comments: