How to make mythbackend start automatically

| | Comments (1) | TrackBacks (0)
In part of my quest to automate the startup of my MythTV, and in my quest for WAF (Wife approval factor), I've identified a few small issues that don't seem terribly well documented anywhere.

I'm going to document them here, as clearly as I can.

This Howto contains a very simple startup script for automatically starting mythbackend on boot.
I'm using Debian lenny/testing, but this will apply to most Debian versions, and perhaps Ubuntu too.

You'll need to create a file, lets call it /etc/init.d/mythbackend, with the following in it.

#!/bin/sh
# Start/stop/restart mythbackend
#
# Modification done by Benoit Beauchamp, based on rc.mysqld by
#
# Copyright 2003 Patrick J. Volkerding, Concord, CA
# Copyright 2003 Slackware Linux, Inc., Concord, CA
#
# This program comes with NO WARRANTY, to the extent permitted by law.
# You may redistribute copies of this program under the terms of the
# GNU General Public License.
#

# Start mythbackend:
myth_start() {
  if [ -x /usr/local/bin/mythbackend ]; then
    # If there is an old PID file (no mythbackend running), clean it up:
    if [ -r /var/run/mythbackend.pid ]; then
      if ! ps axc | grep mythbackend 1> /dev/null 2> /dev/null ; then
        echo "Cleaning up old /var/run/mythbackend.pid."
        rm -f /var/run/mythbackend.pid
      fi
    fi
    /usr/local/bin/mythbackend -l /var/log/mythbackend.log -v important,general -p /var/run/mythbackend.pid -d
  fi
}

# Stop mythbackend:
myth_stop() {
  # If there is no PID file, ignore this request...
  if [ -r /var/run/mythbackend.pid ]; then
    killall mythbackend
  fi
}



# Restart mythbackend:
myth_restart() {
  myth_stop
  myth_start
}

case "$1" in
'start')
  myth_start
  ;;
'stop')
  myth_stop
  ;;
'restart')
  myth_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac
Then you'll have to set that file as executable

chmod +x /etc/init.d/mythbackend
Now, test it and make sure it does what its supposed to.
Make sure mythbackend isn't running, and then try:

/etc/init.d/mythbackend start
Check to see if its running. If not, check all the paths in the script, if it is, hurray!

Now we need to add it to run on boot, and as a bonus, shutdown mythbackend properly on shutdown
We'll do this the Debian Way (tm)

update-rc.d mythbackend defaults 90
And that should do it! Give your machine a reboot and see it mythbackend started on its own.

Categories

,

0 TrackBacks

Listed below are links to blogs that reference this entry: How to make mythbackend start automatically.

TrackBack URL for this entry: http://daffy.za.net/cgi-bin/mt/mt-tb.cgi/59

1 Comments

tpmccright said:

Thank you for a great Howto
At the first of the article when creating a file you specify /etc/init.d/mythfrontend. I think it should be mythbackend instead. I use Kubuntu and the only change I had to make was the location of mythbackend to /usr/bin/mythbackend.

Leave a comment

Powered by Ajax Comments

About this Entry

This page contains a single entry by Kieran Murphy published on October 9, 2007 3:01 PM.

Things that are easier to do in Africa was the previous entry in this blog.

How to make mythfrontend start automatically with X is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Syndicate

Powered by Movable Type 4.01