summaryrefslogtreecommitdiffstats
path: root/abs/mv-core/myth/release-fixes/mythtv-release-fixes/mythbackend.sh
blob: e7a7b7009f09055b9b37aa5b42ae5a0fa02aa7e6 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
#
#	/etc/rc.d/init.d/mythbackend
#
# Starts the mythbackend as a daemon
#
# chkconfig: 345 90 10
# description: Starts the mythbackend process as a daemon after the XWindows \
#              system is started, in runlevel 5. This allows scheduled \
#              recordings to occur without manual intervention.
# processname: mythbackend

# Copyright (c) by Michael Thomson <linux at m-thomson dot net>
# With thanks to Stu Tomlinson <stu at nosnilmot dot com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA

# Default values to use if none are supplied in the config file.
# User who should start the mythbackend processes
MBE_USER="root"
# Directory holding the mythbackend binary
MBE_LOCATION="/usr/local/bin/"
# Name of mythbackend binary
MBE_PROG="mythbackend"
# Full path to mythbackend log file
MBE_LOGFILE="/var/log/mythtv/mythbackend.log"

# Source function library.
. /etc/init.d/functions

# Source config file if available
if [ -f "/etc/sysconfig/mythbackend" ]; then
  . /etc/sysconfig/mythbackend
fi

test -x ${MBE_LOCATION}${MBE_PROG} || exit 0

RETVAL=0

#
#	See how we were called.
#

start() {
	# Check if mythbackend is already running
	if [ ! -f /var/lock/subsys/${MBE_PROG} ]; then
	    echo -n "Starting ${MBE_PROG}: "
	    # /usr/local/bin/mythbackend -d -l /some/log/file
	    #daemon --user ${MBE_USER} ${MBE_LOCATION}${MBE_PROG} -d -l ${MBE_LOGFILE}
	    ${MBE_LOCATION}${MBE_PROG} -d -l ${MBE_LOGFILE}
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/${MBE_PROG}
	    echo
	fi
	return $RETVAL
}

stop() {
	echo -n "Stopping ${MBE_PROG}: "
	killproc ${MBE_LOCATION}${MBE_PROG}
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${MBE_PROG}
	echo
        return $RETVAL
}


restart() {
	stop
	start
}	

reload() {
	restart
}	

status_at() {
 	status ${MBE_LOCATION}${MBE_PROG}
}

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
reload|restart)
	restart
	;;
condrestart)
	if [ -f /var/lock/subsys/${MBE_PROG} ]; then
	    restart
	fi
	;;
status)
	status_at
	;;
*)
	echo "Usage: $0 {start|stop|restart|condrestart|status}"
	exit 1
esac

exit $?
exit $RETVAL