Monday, October 06, 2008

mc2xml on ubuntu

I recently switched to mc2xml for grabbing TV listings from TitanTV. The service doesn't always respond in a timely manner and so I needed a script to retry a couple of times in case it failed the first time. Here is the bash script that I wrote to retry every 60 seconds for 15 minutes. I hope that it helps someone else.

#!/bin/bash

servicebusy=2
repeats=0
maxrepeats=15

cd /home/user/mc2xml
./mc2xml
errorcode=$?

echo Error Code == $errorcode

while [[ $errorcode -eq $servicebusy ]]; do
if [[ $repeats -ge $maxrepeats ]]; then
exit -1
fi
let "repeats += 1"
echo repeating in 60 seconds \( try $repeats of $maxrepeats \)
sleep 60
./mc2xml
errorcode=$?
done

mythfilldatabase --refresh-all --file 1 xmltv.xml
I run it every night with the following command in my crontab

39 2 * * 1-7 bash /home/user/mc2xml/do_mythfill_fixed.sh

Thursday, May 22, 2008

inadyn, opendns, and Ubuntu

I have been using DNS services from OpenDNS.org for a little while now, and I am very happy with some of the features that they provide such as URL shortcuts and finely grained internet filtering. However, in order to use the features, I have to keep my dynamic IP address up to date with their DNS-O-Matic service. Their list of clients includes inadyn, which is available through Ubuntu but doesn't include DNS-O-Matics ssl extensions and so I compiled my own version and installed it.

Here are the steps I followed:

  1. Download modified inadyn source code from OpenDNS -- wget http://www.opendns.com/support/ddns_files/inadyn.source.v1.99.zip
  2. Unzip the source code -- unzip inadyn.source.v1.99.zip
  3. sudo apt-get build-dep inadyn
  4. sudo apt-get install libcurl4-openssl-dev
  5. cd inadyn.source.v1.99
  6. make
  7. sudo cp -p bin/linux/inadyn /usr/local/sbin/.
  8. Create a script named inadyn in /etc/init.d so that it will launch automatically on startup.
    #! /bin/sh

    ### BEGIN INIT INFO
    # Provides: inadyn
    # Required-Start: $network
    # Required-Stop: $syslog
    # Should-Start: $named $syslog
    # Should-Stop: $syslog $network
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Dynamic IP Adress updater
    # Description: inadyn is a program that updates services such as
    # dyndns.org and dnsomatic.com when the host's external
    # external IP address changes.
    ### END INIT INFO

    set -e

    # /etc/init.d/inadyn: start and stop the inadyn daemon

    DAEMON=/usr/local/sbin/inadyn
    INADYN_ENABLE=true
    INADYN_OPTS=''
    INADYN_CONFIG_FILE=/etc/inadyn.conf

    test -x $DAEMON || exit 0

    . /lib/lsb/init-functions
    . /etc/default/rcS

    export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/local/sbin"

    case "$1" in
    start)
    if "$INADYN_ENABLE"; then
    log_daemon_msg "Starting inadyn daemon" "inadyn"
    if [ ! -s "$INADYN_CONFIG_FILE" ]; then
    log_failure_msg "missing or empty config file $INADYN_CONFIG_FILE"
    log_end_msg 1
    exit 1
    fi
    if start-stop-daemon --start --quiet \
    --pidfile /var/run/inadyn.pid --make-pidfile\
    --exec $DAEMON
    then
    rc=0
    else
    rc=1
    fi
    if [ $rc -eq 0 ]; then
    log_end_msg 0
    else
    log_end_msg 1
    fi
    else
    if [ -s "$INADYN_CONFIG_FILE" ]; then
    [ "$VERBOSE" != no ] && log_warning_msg "inadyn daemon not enabled in /etc/init.d/inadyn, not starting..."
    fi
    fi
    ;;
    stop)
    log_daemon_msg "Stopping inadyn daemon" "inadyn"
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
    log_end_msg $?
    ;;
    restart)
    set +e
    if $INADYN_ENABLE; then
    log_daemon_msg "Restarting inadyn daemon" "inadyn"
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON || true
    sleep 1
    if start-stop-daemon --start --quiet \
    --pidfile /var/run/inadyn.pid --make-pidfile \
    --exec $DAEMON
    then
    rc=0
    else
    rc=1
    fi
    if [ $rc -eq 0 ]; then
    log_end_msg 0
    else
    log_end_msg 1
    fi
    else
    [ "$VERBOSE" != no ] && log_warning_msg "inadyn daemon not enabled in /etc/default/inadyn, not starting..."
    fi
    ;;

    *)
    echo "Usage: /etc/init.d/inadyn {start|stop|restart}"
    exit 1
    esac

    exit 0
  9. sudo update-rc.d -f inadyn defaults
  10. Create an inadyn.conf file in /etc
    background
    syslog

    update_period_sec 600 # Check for a new IP every 600 seconds
    secure

    # Enter your DynDNS username and password here
    username <USERNAME GOES HERE>
    password <PASSWORD GOES HERE>

    # What kind of host is being updated? Choices are dyndns@dyndns.org, statdns@dyndns.org, custom@dyndns.org
    dyndns_server_name updates.dnsomatic.com
    dyndns_server_url /nic/update?
    alias <DNS-O-Matic SERVICE 1 GOES HERE>
    alias <DNS-O-Matic SERVICE 2 GOES HERE>

  11. /etc/init.d/inadyn start

  12. all done inadyn is now installed and will keep DNS-o-Matic apprised of you IP address.

New MythTV Box

I just put together a new MythTV box with an Intel Core2 Duo E7200 processor and a Gigabyte GA-73PVM-S2H. My build was based on one I found on another blog, and so far I am very pleased with the results. I used MythBuntu 8.04 for the OS, and despite the fairly minimal install MythBuntu provides, I have gotten everything working rather quickly. I intend to document a couple of the tweaks that I have to make in order to get everything working just right.

Here is a list of the additional packages that I have installed so far with apt-get:

  • unzip
  • nvidia-glx-new
  • nvidia-settings
  • sysvconfig (I like to use the Fedora/RH style 'service' script to stop and restart services)
  • hdhomerun-config

 

Blogger Template by Blogcrowds