[mythtv-users] Gentoo mythfrontend auto-start
Phil Bridges
gravityhammer at gmail.com
Tue Nov 4 13:29:54 UTC 2014
On Tue, Nov 4, 2014 at 6:37 AM, Phil Bridges <gravityhammer at gmail.com>
wrote:
> On Mon, Nov 3, 2014 at 10:25 PM, Hika van den Hoven <hikavdh at gmail.com>
> wrote:
>
>> Hoi Hika,
>>
>> Tuesday, November 4, 2014, 4:19:33 AM, you wrote:
>>
>> > Hoi Phil,
>>
>> > Tuesday, November 4, 2014, 3:18:22 AM, you wrote:
>>
>> >> On Mon, Nov 3, 2014 at 6:32 AM, Phil Bridges <gravityhammer at gmail.com
>> >wrote:
>>
>> >> Thanks, Hiko.
>>
>> >> I've put in your scripts (ignoring the lirc stuff, because I don't
>> >> use it), but I'm getting a syntax error:
>>
>> >> /etc/init.d/mythfrontend: line 38: syntax error near unexpected token
>> `then'
>> >> /etc/init.d/mythfrontend: line 38: ` if [ "$(pgrep -u
>> >> ${MYTH_UID} mythfrontend.re)" ]; then'
>>
>> >> Thoughts?
>>
>> >> On Mon, Oct 27, 2014 at 3:10 PM, Hika van den Hoven <hikavdh at gmail.com>
>> wrote:
>>
>> >> Hoi Phil,
>> >>
>> >> Monday, October 27, 2014, 6:58:34 PM, you wrote:
>> >>
>> >>> I've recently had to rebuild a couple of my (Gentoo) Myth boxes,
>> >>> and I'm not sure exactly what I was using for auto-starting
>> >>> Mythfrontend. What scripts are y'all using for this?
>> >>
>> >>
>> >> I have the following copied from the gentoo-forums and adapted,
>> >>
>> >> in /etc/init.d
>> >>
>> >> #!/sbin/runscript
>> >> # Copyright 1999-2006 Gentoo Foundation
>> >> # Distributed under the terms of the GNU General Public License v2
>> >> # $Header: $
>> >>
>> >> depend() {
>> >> use mythbackend
>> >> }
>> >>
>> >> start() {
>> >>
>> >> ebegin "Starting MythTV Frontend"
>> >>
>> >> eindent
>> >>
>> >> einfo "Starting mythfrontend"
>> >>
>> >> start-stop-daemon --start --quiet --background \
>> >> --user ${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 \
>> >> --user ${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} irxevent)" ]; then
>> >> einfo "Terminating irXevent"
>> >> start-stop-daemon --stop --exec /usr/bin/irxevent \
>> >> --user ${MYTH_UID} --quiet
>> >> eend $?
>> >> fi
>> >>
>> >> if [ "$(pgrep -u ${MYTH_UID} mythfrontend.re)" ]; then
>> >> einfo "Terminating MythFrontend"
>> >> start-stop-daemon --stop --name mythfrontend.re \
>> >> --user ${MYTH_UID} --quiet
>> >> eend $?
>> >> fi
>> >>
>> >> if [ "$(pgrep -u ${MYTH_UID} mythlogserver)" ]; then
>> >> einfo "Terminating mythlogserver"
>> >> start-stop-daemon --stop --name mythlogserver \
>> >> --user ${MYTH_UID} --quiet
>> >>
>> >> eend $?
>> >> fi
>> >>
>> >> if [ "$(pgrep -u ${MYTH_UID} xclock)" ]; then
>> >> einfo "Terminating X"
>> >> start-stop-daemon --stop --name xclock \
>> >> --user ${MYTH_UID} --quiet
>> >> eend $?
>> >> fi
>> >>
>> >> eoutdent
>> >> }
>> >>
>> >> in /etc/conf.d
>> >>
>> >> # 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="mythtv"
>> >>
>> >> # Where irexec can find the lircrc file.
>> >> MYTH_LIRCRC="${HOME}/.mythtv/lircrc"
>> >>
>> >> and ~/.xinitrc
>> >>
>> >> # .xinitrc
>> >> cd
>> >> [ -x /usr/bin/nvidia-settings ] && /usr/bin/nvidia-settings -l
>> >> /usr/bin/xset s noblank
>> >> /usr/bin/xset s off
>> >> /usr/bin/xset -dpms
>> >> #~/.screenlayout/set-768x576i.sh
>> >>
>> >> /usr/bin/evilwm \
>> >> -snap 10 -bw 1 \
>> >> -bg rgb:0/0/3fff -fg rgb:0/0/ffff \
>> >> -app xclock/XClock -s \
>> >> -app xterm/XTerm -g 116x41+11+25 \
>> >> -app xmyth/XTerm -v 0 -g 116x39+11+25 \
>> >> -app xstart/XTerm -v 2 -g 116x39+11+25 \
>> >> -app xvnc/XTerm -v 3 -g 116x39+11+25 \
>> >> -app mythfrontend/Mythfrontend -v 0 &
>> >>
>> >> exec /usr/bin/xterm -name "xmyth" \
>> >> -bg rgb:0/0/3fff \
>> >> -fg rgb:ffff/ffff/ffff \
>> >> -e ~/.scripts/StartMyth.sh &
>> >>
>> >> exec /usr/bin/xterm -name "xstart" \
>> >> -xrm "XTerm.vt100.allowSendEvents: true" \
>> >> -bg rgb:0/0/3fff \
>> >> -fg rgb:ffff/ffff/ffff \
>> >> -e /bin/bash &
>> >>
>> >> exec /usr/bin/xterm -name "xvnc" \
>> >> -bg rgb:0/0/3fff \
>> >> -fg rgb:ffff/ffff/ffff \
>> >> -e ~/.scripts/StartVnc.sh &
>> >>
>> >> exec xclock -digital -padding 2 -norender -g -0+0 \
>> >> -bg rgb:0/0/3fff \
>> >> -fg rgb:ffff/ffff/ffff
>> >>
>> >> and StartMyth.sh
>> >>
>> >> #!/bin/bash
>> >> while true; do
>> >> /usr/bin/mythfrontend --syslog local7
>> >> read x
>> >> clear
>> >> done
>> >>
>> >> The clock is this way the X-closing application. Running the frontend
>> >> from an Xterm makes the log with an Alt-tab visible. The loop lets me
>> >> easily restart. (Actually it has a whole menu with reboot, hibernate
>> >> etc. options). The vnc script has a similar loop to restart it. The
>> >> extra xterm is there in place of a normal text terminal. The TV is
>> >> interlaced vga to scart, so I can't get a normal console other than
>> >> ssh.
>> >>
>> >> It appears to not like that position of any of the three if/thens.
>>
>> > Sorry I didn't react, I apparently didn't get your earlier mail.
>>
>> > What do you get if you run pgrep on the command line? (Pgrep is a
>> > combination of ps and grep. pgrep <name> is the same as ps -A | grep
>> > <name> where -u ${MYTH_UID} filters on processes owned by ${MYTH_UID})
>>
>> > I think your error comes from "$(pgrep -u ${MYTH_UID}
>> > mythfrontend.re)" giving an unexpected result, most probable because
>> > the MYTH_UID you have defined in /ect/conf.d/mythfrontend doesn't
>> > exist. In my script the user is mythtv, so either you change it to
>> > another user or if it doesn't exists create it. Also the user needs a
>> > correct user directory etc.
>>
>> Another possibility comes to mind. Did you mistype MYTH_UID in
>> /ect/conf.d/mythfrontend? If so the variable is empty and it takes
>> mythfrontend.re as the username and complains about an invalid
>> username and a missing argument.
>>
>>
> Thank for the response, Hika.
>
> pgrep -u mythtv mythfrontend.re
>
> returns no error (I don't have mythfrontend running at the time, so it
> returns nothing)
>
> In conf.d, I have:
>
> # User id that all the processes should run as.
> MYTH_UID="mythtv"
>
> mythtv is a valid user, and the home directory is there. Also, if the
> MYTHUID were bad, wouldn't the init.d script bomb in here?
>
> start-stop-daemon --start --quiet --background \
> --user ${MYTH_UID} \
> --exec /usr/bin/startx \
> -- -- ${MYTH_XOPTS} vt${MYTH_VT}
>
>
>
OK - I ssh'd in from work, and when I went to edit the init.d file, I
noticed there were odd characters where tabs should be. Deleted those and
replaced them with tabs, and the script runs. Unfortunately, it shows
mythfrontend as crashed immediately. Time to delve in to what is causing
that.
Thanks for the help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20141104/f1212c77/attachment.html>
More information about the mythtv-users
mailing list