View previous topic :: View next topic |
Author |
Message |
zephirus n00b
Joined: 21 Nov 2003 Posts: 66
|
Posted: Thu Jan 19, 2006 1:16 am Post subject: help on scripts to start myth for HTPC |
|
|
I need scripts to start X during the default runtime without a display manager, and to start mythfrontend on X start wait for mythfrontend to exit and issue a halt command.
I know I can start mythfrontend through .xinitrc when X starts, but not sure how to elegantly script the rest... I would post my guess, but I would be embarassed by showing my nonexistant bash scripting skills.
Can anyone help me please?[/code] |
|
Back to top |
|
|
Bad Penguin Guru
Joined: 18 Aug 2004 Posts: 507
|
Posted: Thu Jan 19, 2006 5:05 am Post subject: Re: help on scripts to start myth for HTPC |
|
|
zephirus wrote: | I need scripts to start X during the default runtime without a display manager, and to start mythfrontend on X start wait for mythfrontend to exit and issue a halt command.
I know I can start mythfrontend through .xinitrc when X starts, but not sure how to elegantly script the rest... I would post my guess, but I would be embarassed by showing my nonexistant bash scripting skills.
Can anyone help me please?[/code] |
Here is my init.d/mythfrontend init script. Note I run the frontend as user "mythuser"...
Code: |
#!/sbin/runscript
# /etc/init.d/mythfrontend
#depend() {
# need mythbackend
#}
start() {
ebegin "Starting MythTV"
/bin/rm -f /var/log/mythtv/frontend.log >/dev/null 2>&1
/bin/touch /var/log/mythtv/frontend.log >/dev/null 2>&1
/bin/chown mythuser /var/log/mythtv/frontend.log >/dev/null 2>&1
/bin/su - mythuser -c "/home/mythuser/bin/startmyth >/var/log/mythtv/frontend.log 2>&1" &
eend ${?}
return 0
}
stop() {
ebegin "Stopping MythTV"
killall -9 mythfrontend
eend 0
}
|
And /home/mythuser/bin/startmyth:
Code: |
#!/bin/bash
KDEDIR=/usr/kde/3.4
KDEDIRS=/usr
PATH='/bin:/usr/bin:/usr/local/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.4:/usr/X11R6/bin:/usr/qt/3/bin:/usr/kde/3.4/bin:~/bin'
QTDIR=/usr/qt/3
export KDEDIR KDEDIRS PATH QTDIR
killall mythfrontend >/dev/null 2>&1
sleep 5
startx -- -dpi 100
|
And finally, /home/mythuser/.xinitrc. Note the xvattr command is specific to my nvidia video card, you probably won't need it... I use ratpoison as the window manager, which is perfect for mythtv.
Code: |
#!/bin/sh
# $Xorg: xinitrc.cpp,v 1.3 2000/08/17 19:54:30 cpqbld Exp $
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap
# merge in defaults and keymaps
if [ -f $sysresources ]; then
xrdb -merge $sysresources
fi
if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi
if [ -f $userresources ]; then
xrdb -merge $userresources
fi
if [ -f $usermodmap ]; then
xmodmap $usermodmap
fi
xsetroot -solid black
xset -dpms s off s noblank s noexpose
if [ -f /tmp/nomyth ]; then
echo "/tmp/nomyth exists, aborting"
exit
fi
/usr/bin/ratpoison &
/usr/bin/xvattr -a XV_COLORKEY -v 66048
/usr/bin/mythfrontend
|
|
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20485
|
Posted: Fri Jan 20, 2006 8:31 pm Post subject: |
|
|
Moved from Other Things Gentoo _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
zephirus n00b
Joined: 21 Nov 2003 Posts: 66
|
Posted: Tue Jan 24, 2006 11:09 pm Post subject: |
|
|
Thanks for the help... I am gonna give 'em a try in my environment tonight. |
|
Back to top |
|
|
Bad Penguin Guru
Joined: 18 Aug 2004 Posts: 507
|
Posted: Wed Jan 25, 2006 3:06 am Post subject: |
|
|
zephirus wrote: | Thanks for the help... I am gonna give 'em a try in my environment tonight. |
If you end up using mythweb, you might find this backend init script useful... Mythweb tends to crash my backend.
/etc/init.d/mythbackend
Code: |
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-tv/mythtv/files/mythbackend.rc6,v 1.4 2004/09/11 12:06:33 aliz Exp $
opts="${opts} restart_if_crashed"
depend() {
need net
use mysql
}
checkconfig() {
for i in $(groups "${MYTH_USER/:*/}") ; do
[ "${i}" = "audio" ] && audio="yes"
[ "${i}" = "video" ] && video="yes"
done
if [ -z "${audio}" -o -z "${video}" ] ; then
ewarn ""
[ -z "${audio}" ] && \
ewarn "${HILITE}${MYTH_USER/:*/}${NORMAL} is not in the audio group"
[ -z "${video}" ] && \
ewarn "${HILITE}${MYTH_USER/:*/}${NORMAL} is not in the video group"
ewarn ""
ewarn "insufficient permissions discovered"
ewarn "mythbackend may not start correctly"
ewarn ""
fi
}
start() {
[ -z "${MYTH_USER}" ] && MYTH_USER="nobody:nobody"
[ -z "${MYTH_LOG}" ] && MYTH_LOG="/var/log/mythtv/mythbackend.log"
[ -z "${MYTH_PID}" ] && MYTH_PID="/var/run/mythtv/mythbackend.pid"
[ -z "${MYTH_WARN}" -o "${MYTH_WARN}" = "yes" ] && checkconfig
HOME="$(dirname "${MYTH_PID}")"
QTDIR=/usr/qt/3
# Work around any strange permissions that may be on these files.
chown -R "${MYTH_USER}" "$(dirname "${MYTH_LOG}")"
chown -R "${MYTH_USER}" "$(dirname "${MYTH_PID}")"
ebegin "Starting myth backend"
start-stop-daemon --start --quiet --chuid "${MYTH_USER}" \
--exec /usr/bin/mythbackend -- \
--daemon --pidfile "${MYTH_PID}" --logfile "${MYTH_LOG}" \
--verbose ${MYTH_VERBOSE}
eend $?
}
stop () {
[ -z "${MYTH_PID}" ] && MYTH_PID="/var/run/mythtv/mythbackend.pid"
ebegin "Stopping myth backend"
start-stop-daemon --stop --quiet --pidfile="${MYTH_PID}"
rc=$?
rm -f ${MYTH_PID}
eend $rc
}
restart() {
svc_stop
sleep 1
svc_start
eend $?
}
restart_if_crashed() {
MYTH_PID="/var/run/mythtv/mythbackend.pid"
[ ! -f "${MYTH_PID}" ] && return 0
pidof mythbackend >/dev/null 2>&1 && return 0
svc_stop
sleep 1
svc_start
return $?
}
|
And the crontab entry that checks it every 5 minutes to restart it if it is crashed...
Code: |
*/5 * * * * /etc/init.d/mythbackend restart_if_crashed >/dev/null 2>&1
|
|
|
Back to top |
|
|
|