Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
MythTV: mythfrontend init script
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
thatdude
n00b
n00b


Joined: 13 Mar 2005
Posts: 14

PostPosted: Thu Jun 08, 2006 2:53 am    Post subject: MythTV: mythfrontend init script Reply with quote

I've written an init script for mythfrontend, and thought I'd post it here in case it might be of use to anyone else. It isn't meant to cover all setups or situations, just to work well for my all-in-one setup, and be a little flexible.

I originally had startx (and thus mythfrontend) being started via an entry in /etc/inittab, but I didn't like that I would see the boot messages for a couple of seconds between the time that the gensplash image disappeared and when X started. I needed something to start startx earlier, and this did the trick. I no longer have to look at those boot messages, and this approach seems cleaner to me, too.

/etc/init.d/mythfrontend:
Code:
#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
        need mythbackend
}

start() {

        ebegin "Starting MythTV Frontend"

        eindent

        einfo "Starting mythfrontend"

        start-stop-daemon --start --quiet --background \
                --chuid ${MYTH_UID} \
                --exec /usr/bin/startx \
                -- -- ${MYTH_XOPTS} vt${MYTH_VT}
        eend $?

        if [ -n "${MYTH_IREXEC}" ]; then

                local name_opt="${MYTH_IREXEC_NAME:+--name ${MYTH_IREXEC_NAME}}"

                einfo "Starting irexec"
                start-stop-daemon --start --quiet \
                        --chuid ${MYTH_UID} \
                        --exec /usr/bin/irexec \
                        -- --daemon ${name_opt} ${MYTH_LIRCRC}
                eend $?
        fi

        eoutdent
}

stop() {
        ebegin "Stopping MythTV Frontend"

        eindent

        # Make an assumption here: if there are any of these programs running
        # under MYTH_UID, then this script started them, and now needs to kill
        # them.

        if [ "$(pgrep -u ${MYTH_UID} irexec)" ]; then
                einfo "Terminating irexec"
                start-stop-daemon --stop --exec /usr/bin/irexec \
                        --user ${MYTH_UID} --quiet
                eend $?
        fi

        if [ "$(pgrep -u ${MYTH_UID} mythfrontend)" ]; then
                einfo "Terminating mythfrontend"
                start-stop-daemon --stop --name mythfrontend \
                        --user ${MYTH_UID} --quiet
                eend $?
        fi

        if [ "$(pgrep -u ${MYTH_UID} mythwelcome)" ]; then
                einfo "Terminating mythwelcome"
                start-stop-daemon --stop --name mythwelcome \
                        --user ${MYTH_UID} --quiet

                eend $?
        fi

        eoutdent
}


/etc/conf.d/mythfrontend:
Code:
# User id that all the processes should run as.
MYTH_UID="mythtv"

# HOME directory.  Needed to find .xinitrc file and .mythtv directory.
HOME="/home/${MYTH_UID}"

# X runs on the first VT available.  At the point this script runs during
# system start-up, the gettys haven't started yet, so the first available VT is
# VT2.  Then, when the getty on VT2 starts, it grabs the keyboard away from X.
# To avoid having to turn off gettys in /etc/inittab, tell X where to find an
# "unreserved" VT.
MYTH_VT="7"

# If there are any other X server options you want to use, set them here.
MYTH_XOPTS="-nolisten tcp -br"

# irexec, part of the lirc package, can be used to run commands in response to
# remote control button presses.  If this variable is set, then irexec will be
# started and pointed to the appropriate config file.  Leave this blank or null
# to not start irexec.
MYTH_IREXEC="yes"

# Name that irexec is configured to respond to in the lircrc file.
MYTH_IREXEC_NAME="mythirexec"

# Where irexec can find the lircrc file.
MYTH_LIRCRC="${HOME}/.mythtv/lircrc"


/home/mythtv/.xinitrc:
Code:
xset -dpms s off
fvwm &
/usr/bin/mythwelcome


That's it.
Back to top
View user's profile Send private message
thesnowman
Guru
Guru


Joined: 08 May 2003
Posts: 365
Location: Sydney, Australia

PostPosted: Sat Jul 15, 2006 4:37 am    Post subject: Reply with quote

Thanks thatdude. Works great and much better than patching inittab.
Back to top
View user's profile Send private message
afabco
Guru
Guru


Joined: 24 Feb 2004
Posts: 380

PostPosted: Sat Jul 15, 2006 7:44 pm    Post subject: Reply with quote

Very nice. This is the first one I've tried that's actually worked consistently. (other than an xterm).

one question. When I start from an xterm, I turn on logging using the "-v all -l /home/mythtv/mythfrontend.log" options.

Where would I set those up?
_________________
Anyone who puts a small gloss on a fundamental technology, calls it proprietary, and then tries to keep others from building on it, is a thief.
-Tim O'Reilly
Back to top
View user's profile Send private message
thatdude
n00b
n00b


Joined: 13 Mar 2005
Posts: 14

PostPosted: Mon Jul 17, 2006 1:14 am    Post subject: Reply with quote

afabco,

If you're using mythwelcome, those settings can be configured there. Hit F11 while in mythwelcome to get to the configuration screen where you can set the mythfrontend start-up command.

If you don't have a need for mythwelcome, then replace its command in .xinitrc with your mythfrontend command.
Back to top
View user's profile Send private message
belrpr
Guru
Guru


Joined: 22 May 2006
Posts: 440

PostPosted: Mon Jul 17, 2006 7:11 am    Post subject: Reply with quote

I don't really get what this does.

I am creating my own mythtv right now and I use fluxbox and start mythtv frontend like that.
Tried using directfb to start it but due lack of documentation I stopped trying.

Do you care to explain a bit to quite a linux noob?
Back to top
View user's profile Send private message
afabco
Guru
Guru


Joined: 24 Feb 2004
Posts: 380

PostPosted: Tue Jul 18, 2006 12:28 am    Post subject: Reply with quote

thatdude:

Thanks!

I wasn't really quite sure what else mythwelcome did (my server stays on 24/7) so was hesitant to replace the code with mythfrontend.

Appreciate it.
_________________
Anyone who puts a small gloss on a fundamental technology, calls it proprietary, and then tries to keep others from building on it, is a thief.
-Tim O'Reilly
Back to top
View user's profile Send private message
afabco
Guru
Guru


Joined: 24 Feb 2004
Posts: 380

PostPosted: Tue Jul 18, 2006 12:29 am    Post subject: Reply with quote

belrpr:

Do you have to manually log in each time the mythtv box fires up? Or does it just automagically come up to the mythfrontend screen?
_________________
Anyone who puts a small gloss on a fundamental technology, calls it proprietary, and then tries to keep others from building on it, is a thief.
-Tim O'Reilly
Back to top
View user's profile Send private message
riscycdj
n00b
n00b


Joined: 09 Oct 2005
Posts: 61

PostPosted: Tue Jul 18, 2006 4:39 am    Post subject: Reply with quote

I use KDM to automatically log the mythtv user on the local box.
Back to top
View user's profile Send private message
belrpr
Guru
Guru


Joined: 22 May 2006
Posts: 440

PostPosted: Tue Jul 18, 2006 10:08 am    Post subject: Reply with quote

afabco wrote:
belrpr:

Do you have to manually log in each time the mythtv box fires up? Or does it just automagically come up to the mythfrontend screen?

I need to login in shell then startx which will start fluxbox and mythtv in the process.

So basicly this script makes an autologin and starts mythtv?
Back to top
View user's profile Send private message
riscycdj
n00b
n00b


Joined: 09 Oct 2005
Posts: 61

PostPosted: Tue Jul 18, 2006 9:58 pm    Post subject: Reply with quote

Look at http://gentoo-wiki.com/HOWTO_Setup_MythTV#KDM
Back to top
View user's profile Send private message
Nicias
Guru
Guru


Joined: 06 Dec 2005
Posts: 396

PostPosted: Tue Jul 18, 2006 10:06 pm    Post subject: Reply with quote

Here is my method: This is the last line of my /etc/conf.d/local.start:
Code:
cd ~myth
su myth -c 'source /etc/profile;startx'

Then here is myth's .xinitrc:
Code:
[ -f $HOME/.Xdefaults ] && xrdb $HOME/.Xdefaults
xsetroot -solid \#400040
xsetroot -cursor_name top_left_arrow
/usr/bin/fluxbox &
setxkbmap  -rules xorg -symbols remote -compat basic
v4lctl volume mute off
exec ~/mythwhile.sh

Then here is the script mythwhile.sh:
Code:
#!/bin/bash

while true
  do /usr/bin/mythfrontend
done


Mythfrontend gets started automatically on startup.
Back to top
View user's profile Send private message
DocterD
Tux's lil' helper
Tux's lil' helper


Joined: 15 May 2004
Posts: 129

PostPosted: Mon Sep 04, 2006 4:05 pm    Post subject: Reply with quote

maybe you can mtd support and something that respawned mythfrontend when it crashes?
Back to top
View user's profile Send private message
belrpr
Guru
Guru


Joined: 22 May 2006
Posts: 440

PostPosted: Tue Sep 05, 2006 8:26 am    Post subject: Reply with quote

What does this do:
Quote:
/home/mythtv/.xinitrc:
Code:
xset -dpms s off
fvwm &
/usr/bin/mythwelcome
Back to top
View user's profile Send private message
dreadhead
Guru
Guru


Joined: 09 Jul 2004
Posts: 470
Location: Ulm - Germany

PostPosted: Tue Sep 05, 2006 8:35 am    Post subject: Reply with quote

belrpr wrote:
What does this do:
Quote:
/home/mythtv/.xinitrc:
Code:
xset -dpms s off
fvwm &
/usr/bin/mythwelcome


When X is started ba user mythtv, X looks into that file for some commands to execute. Is basically like an autorun for X. First it turns off dpms (So that the screensaver isn't coming on while watching TV) and then it starts fvwm. After this it starts the frontend.
_________________
Kopete OTR Plugin
Back to top
View user's profile Send private message
belrpr
Guru
Guru


Joined: 22 May 2006
Posts: 440

PostPosted: Tue Sep 05, 2006 12:24 pm    Post subject: Reply with quote

dreadhead wrote:
belrpr wrote:
What does this do:
Quote:
/home/mythtv/.xinitrc:
Code:
xset -dpms s off
fvwm &
/usr/bin/mythwelcome


When X is started ba user mythtv, X looks into that file for some commands to execute. Is basically like an autorun for X. First it turns off dpms (So that the screensaver isn't coming on while watching TV) and then it starts fvwm. After this it starts the frontend.


Ah ok but what is fvwm?
BTW there is no need for a window manager like fluxbox or kde or gnome?
Back to top
View user's profile Send private message
Icer
Guru
Guru


Joined: 26 Aug 2003
Posts: 395
Location: @home

PostPosted: Tue Sep 05, 2006 12:44 pm    Post subject: Reply with quote

belrpr wrote:
dreadhead wrote:
belrpr wrote:
What does this do:
Quote:
/home/mythtv/.xinitrc:
Code:
xset -dpms s off
fvwm &
/usr/bin/mythwelcome


When X is started ba user mythtv, X looks into that file for some commands to execute. Is basically like an autorun for X. First it turns off dpms (So that the screensaver isn't coming on while watching TV) and then it starts fvwm. After this it starts the frontend.


Ah ok but what is fvwm?
BTW there is no need for a window manager like fluxbox or kde or gnome?

AFAIK fvwm is a window manager. So I would assume that you need a window manager.
_________________
Everything can be done. There's just a longer delivery time for impossible projects.
Back to top
View user's profile Send private message
dreadhead
Guru
Guru


Joined: 09 Jul 2004
Posts: 470
Location: Ulm - Germany

PostPosted: Tue Sep 05, 2006 2:23 pm    Post subject: Reply with quote

Yes. fvwm is a window manager. There is no need to use a windowmanager for mythfrontend but the devs say that it is only tested with a wm and you could run into window focusing problems. I had mythfe running without a wm and I have seen this problems. Sometimes when a warning message comes up (for example that the connection to the backend is lost) you cannot see it because it appears behind the frontend. Since I use a wm I haven't seen this problem any more.

Most people use fvwm because it would be senseless to compile kde or gnome for many hours while all the features they offer aren't used. fvwm is just a wm without any other tools.
_________________
Kopete OTR Plugin
Back to top
View user's profile Send private message
Hobbes-X
l33t
l33t


Joined: 04 Feb 2004
Posts: 823
Location: Seattle, WA

PostPosted: Thu Oct 19, 2006 3:27 pm    Post subject: Re: MythTV: mythfrontend init script Reply with quote

thatdude wrote:
I've written an init script for mythfrontend, and thought I'd post it here in case it might be of use to anyone else. It isn't meant to cover all setups or situations, just to work well for my all-in-one setup, and be a little flexible.

I originally had startx (and thus mythfrontend) being started via an entry in /etc/inittab, but I didn't like that I would see the boot messages for a couple of seconds between the time that the gensplash image disappeared and when X started. I needed something to start startx earlier, and this did the trick. I no longer have to look at those boot messages, and this approach seems cleaner to me, too.


thatdude- This is exactly what I was dreading trying to make on my own, thank you very much for posting this and saving me a lot of research and work! :D
Back to top
View user's profile Send private message
Hobbes-X
l33t
l33t


Joined: 04 Feb 2004
Posts: 823
Location: Seattle, WA

PostPosted: Thu Oct 19, 2006 4:50 pm    Post subject: Reply with quote

DocterD wrote:
maybe you can mtd support and something that respawned mythfrontend when it crashes?


If you have mythdvd installed from the ebuilds in portage, there's an init script already existing for mtd:
Code:

To have Myth Transcode Daemon (mtd) start on boot do the following
rc-update add mtd default
Make sure you run 'mtd -n' to setup mtd first
Back to top
View user's profile Send private message
theBlackDragon
l33t
l33t


Joined: 23 Nov 2002
Posts: 758
Location: Gent (Belgium)

PostPosted: Fri Oct 20, 2006 10:38 am    Post subject: Reply with quote

dreadhead wrote:
Yes. fvwm is a window manager. There is no need to use a windowmanager for mythfrontend but the devs say that it is only tested with a wm and you could run into window focusing problems. I had mythfe running without a wm and I have seen this problems. Sometimes when a warning message comes up (for example that the connection to the backend is lost) you cannot see it because it appears behind the frontend. Since I use a wm I haven't seen this problem any more.

Most people use fvwm because it would be senseless to compile kde or gnome for many hours while all the features they offer aren't used. fvwm is just a wm without any other tools.


That would be quite underestimating FVWM, but anyway. Why use FVWM and not twm? I think (I'm not sure though) that twm still comes with Xorg by default, so why compile FVWM if twm is already there?
_________________
Fvwm|Fvwm forum
Back to top
View user's profile Send private message
Hobbes-X
l33t
l33t


Joined: 04 Feb 2004
Posts: 823
Location: Seattle, WA

PostPosted: Fri Oct 20, 2006 1:17 pm    Post subject: Reply with quote

theBlackDragon wrote:
That would be quite underestimating FVWM, but anyway. Why use FVWM and not twm? I think (I'm not sure though) that twm still comes with Xorg by default, so why compile FVWM if twm is already there?


IIRC there's been reports of window focus issues with twm, but only in certain cases- like when starting an external program when all the window decorations are disabled? Entirely hearsay of course, since there's all sorts of problems caused by user configuration...
Back to top
View user's profile Send private message
JloR
n00b
n00b


Joined: 29 Jun 2004
Posts: 43
Location: Denmark

PostPosted: Sun Nov 12, 2006 5:15 pm    Post subject: Reply with quote

THANK YOU! I've just figured out why my system was hanging just after udev... Damn ivtv / kernel-2.6.18 problem! So.. After spending 2 weeks trying to figure that out I'm happe I found this treasure :)


Thanks a lot.. Saved me some work :) Now to setup lirc for mythtv - and figure out why one of the cards in the machine only work 50% of the time.. :) But that's a completely different problem.
_________________
-- Jakob L. O. Rosenlund
Back to top
View user's profile Send private message
derheld42
Tux's lil' helper
Tux's lil' helper


Joined: 31 Mar 2003
Posts: 97
Location: Washington, US

PostPosted: Wed Apr 04, 2007 6:14 am    Post subject: Reply with quote

Just have to say thanx a bundle for this script!

I had rigged something up in /etc/X11/startdm.sh, which essentially accomplished the same thing, but your approach isn't just a hack. It's adds a good degree of flexibility.

I think it should be submitted to the gentoo mythtv ebuild. :)

Users can choose to use it if they want to....
Back to top
View user's profile Send private message
dpl
Tux's lil' helper
Tux's lil' helper


Joined: 22 Apr 2003
Posts: 137
Location: Canada

PostPosted: Fri May 04, 2007 8:42 pm    Post subject: Reply with quote

I just set up my mthtv box, and was looking for something to do exactly this... I have fluxbox autostart mythfrontend, but that didn't quite do it. I also wanted something that would not require either kdm or gdm, and this was spectacular!

dpl
_________________
puto risi vidi
Back to top
View user's profile Send private message
thatdude
n00b
n00b


Joined: 13 Mar 2005
Posts: 14

PostPosted: Fri May 04, 2007 9:29 pm    Post subject: Reply with quote

I'm glad to hear that this has helped a few people out.

Since I first posted, I discovered that irexec had its own init script (duh!), split my all-in-one box into physically separate frontend and backend machines, and stopped using a window manager with no ill effects.

Here is the simpler version currently running on my net-booting frontend...

/etc/init.d/mythfrontend:
Code:

#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
        use net irexec mythbackend
}

start() {

        ebegin "Starting MythTV Frontend"

        start-stop-daemon --start --quiet --background \
                --chuid ${MYTH_UID} \
                --exec /usr/bin/startx \
                -- -- ${MYTH_XOPTS} vt${MYTH_VT}
        eend $?

}

stop() {

        ebegin "Stopping MythTV Frontend"

        # Make an assumption here: if there are any of these programs running
        # under MYTH_UID, then this script started them, and now needs to kill
        # them.

        if [ "$(pgrep -u ${MYTH_UID} xinit)" ]; then
                start-stop-daemon --stop --name xinit \
                        --user ${MYTH_UID} --quiet
                eend $?
        fi

}


The "use mythbackend" above should make it run in the right spot on a box that runs both the frontend and backend.

/etc/conf.d/mythfrontend:
Code:

# User id that all the processes should run as.
MYTH_UID="mythtv"

# HOME directory.  Needed to find .xinitrc file and .mythtv directory.
HOME="/home/${MYTH_UID}"

# X runs on the first VT available.  At the point this script runs during
# system start-up, the gettys haven't started yet, so the first available VT is
# VT2.  Then, when the getty on VT2 starts, it grabs the keyboard away from X.
# To avoid having to turn off gettys in /etc/inittab, tell X where to find an
# "unreserved" VT.
MYTH_VT="7"

# If there are any other X server options you want to use, set them here.
MYTH_XOPTS="-nolisten tcp -br -dpi 100"


/home/mythtv/.xinitrc:
Code:

/usr/local/bin/xwarppointer abspos 720 480
/usr/bin/xset -dpms s off
while :; do
        /usr/bin/mythfrontend -v important,general -l /var/log/mythtv/mythfrontend.log
done


The loop in .xinitrc allows mythfrontend to automatically restart if it dies, or if I kill it using a button on my remote. The init script is still able to stop mythfrontend because it kills the script running the loop.

I may take the suggestion to submit this for inclusion in the mythtv ebuild, but I wouldn't count on it getting in since there is already a different "autostart" method that the ebuild sets up when that use flag is enabled.

Enjoy!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum