summaryrefslogtreecommitdiff
path: root/multimedia/mythtv/files/rc.mythbackend.new
blob: 7cb2683e6c5aff95d77cf70df520813bdae2006b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/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.
#
LOG=/var/log/mythbackend.log
PID=/var/run/mythbackend.pid
MYTHTV_HOME=/etc/mythtv
export MYTHCONFDIR="$MYTHTV_HOME"
export HOME="$MYTHTV_HOME"

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

# Stop mythbackend:
myth_stop() {
  # If there is no PID file, ignore this request...
  if [ -r $PID ]; then
    echo "Stopping mythbackend..."
    killall mythbackend
    rm -f $PID
  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