[mythtv-users] Trouble running mythbackend service

R. G. Newbury newbury at mandamus.org
Sun Jul 9 22:15:43 UTC 2006


Ryan Steffes wrote:
> 
> 
> On 7/4/06, *Will Constable* <willconstable at gmail.com 
> <mailto:willconstable at gmail.com>> wrote:
> 
>     I am running a fresh fedora core 5 install and have only upgraded
>     its standard packages, added nvidia driver, and installed
>     mythtv-suite.  I am trying to get mythbackend to run as a service,
>     but have a problem.  Chkconfig mythbackend is set to on in runlevel
>     5, and /sbin/service mythbackend status yields the message
>     'mythbackend dead but pid file exists' or something like that.  If I
>     run the script directly from the /etc/init.d/ folder (./mythbackend
>     start) I get this error:

>     Starting mythbackend: touch: cannot touch
>     '/var/run/mythbackend.pid': Permission denied
> 
>     Chown: cannot access 'var/run/mythbackend.pid' No such file or directory
> 
>     Cannot open logfile /var/log/mythtv/mythbackend.log
> 
>     Cannot open loogfile; using stdout/stderr
> 
>     /var/run/mythbackend.pid: Permission denied
> 
>     Error opening pidfile
> 
>     Should there be a pidfile before I start the service?  If I
>     understand correctly the pid files are created as processes run and
>     deleted as processes terminate.  If I run the command 'sudo
>     ./mythbackend start' everything works as it should.  Except
>     mythbackend is running as root, of course.  Any ideas?
> 
>      
> 
>     Thanks,
> 
>     Will Constable
> 
> 
> 
> Looks like the pid file was created when you were running as root, and 
> now your mythtv user can't overwrite it.  You need sudo rm /v 
> ar/run/mythbackend.pid  and you also need to chown the log file to the 
> mythtv user or set it to group/world writeable.


Been fighting with this on and off too. The problem here is that 
services are started as root. If something goes wrong, user mythtv 
cannot clean out the leftovers and fix things.

Generally, running 'service mythbackend restart' will clean up things, 
but user mythtv cannot run that.

I have had no luck with 'chmod'ing and 'chown'ing the /var/lock/subsys/ 
folder or even changing the ownership of mythbackend and/or mythfrontend.

As far as I can tell you have 2 choices:

Door 'A' has the startup of your programs deferred until after the 
autologin of user mythtv. I have not used this route. You need to add 
scripts to ~/.kde/Autotstart. These will be autostarted on login. Best 
to use a numbering scheme as in rc5.d to ensure the proper start order.
Since the running processes then 'belong' to user mythtv, there are no 
problems with starting and stopping. BUT NOTE that this means that they 
are not started as services. The example below would probably need a 
'&&' at the end of the calling line to make it run as a background process.

The following is modified from a Gentoo wiki (thanks to whoever!):
***********************
Programs that you wish to autostart on KDE startup need to be placed 
into ~/.kde/Autostart.

Below is an example of autostarting GAIM using in bash.

cd ~/.kde/Autostart
Using your favourite editor create a file called 'gaim' containing:

#!/bin/bash
/usr/bin/gaim

Remember to:
chmod +x ~/.kdr/Autostart/gaim
**************************


Door 'B' has user mythtv given essentially complete authority by editing 
the file /etc/sudoers. If you have or will have multiple mythboxes and 
therefore multiple myth-users, make sure that they are all members of 
the group 'mythtv' and give the group '%mythtv' full privileges. Give 
the 'NOPASSWORD = ALL' setting too.

Now any user in group mythtv can enter 'sudo service mythbackend restart'
and it will be done as if ordered by user 'root'.

To make it easier, you may want to create some scripts in 
/home/mythtv/bin which have will do the cleanup. If you do not wish to 
remember different commands, then create alias scripts in 
/home/myththv/bin, where 'service' there is actually 'sudo service'. Add 
/home/mythtv/bin to the *beginning* of user mythtv's PATH so the alias 
is called first.

I have just written a script 'resetmyth' which will restart mythbackend 
and mythfrontend. It has an icon on the (mythtv) desktop. Hopefully, 
that will meet with some sort of acceptance by my wife, as I cannot see 
her typing in commands to get myth back up and running. I'm not even 
sure that a power button restart will be acceptable!


Of course none of this would be necessary, if it possible to auto-login 
as root. I know that this is frowned upon (or worse) but it is just 
plain stupid that it cannot be done... There are places where running as 
root is necessary. I happen to think that the mythtv situation is one of 
those situations, where recovery from a problem is needed and the user 
has no computer experience. I have to have this as easy as using the VCR 
remote *under all conditions* or the WAF will be zero.

Geoff


More information about the mythtv-users mailing list