[Solved] DVB Card - Can't open ...

For discussion of topics specific to MythTV on linux
Post Reply
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

[Solved] DVB Card - Can't open ...

Post by AndyInNYC »

I've been beating my head on the wall on this and my google-fu must be weak.

In Mythtv-setup, the two cards in the system can't be opened unless I run the setup as root. All my reading leads me to believe that this is a permission problem.

I'm running a new install on Ubuntu 16.04 and mythtv .28

The user 'server' is the main login for the system.

The error I'm getting supposedly traces back to permissions on the dvb cards. I've tried changing the owners to get around this problem (root root owned the dvb cards initially). If I type
ls -l /dev/dvb/adapter?/* I get back

Code: Select all

crw-rw----+ 1 root video 212, 0 May 10 17:42 /dev/dvb/adapter0/demux0
crw-rw----+ 1 root video 212, 1 May 10 17:42 /dev/dvb/adapter0/dvr0
crw-rw-rw-+ 1 root video 212, 3 May 10 17:42 /dev/dvb/adapter0/frontend0
crw-rw----+ 1 root video 212, 2 May 10 17:42 /dev/dvb/adapter0/net0
crw-rw----+ 1 root video 212, 5 May 10 17:42 /dev/dvb/adapter1/demux0
crw-rw----+ 1 root video 212, 6 May 10 17:42 /dev/dvb/adapter1/dvr0
crw-rw-rw-+ 1 root video 212, 4 May 10 17:42 /dev/dvb/adapter1/frontend0
crw-rw----+ 1 root video 212, 7 May 10 17:42 /dev/dvb/adapter1/net0
If I look to see who is in group video I get:

Code: Select all

server@Server:~$ grep video /etc/group
video:x:44:mythtv,root,server
So, basically everybody who should have access to the DVB cards does (I think).

To some extent, I wouldn't mind elevating mythbackend to root status if it gets around this problem - I'm just not sure how to run it that way on startup.

As an addendum, can I add the ppa AFTER I've installed the mythtv's backend (ie now)? Perhaps this might fix my issues or help fix. I crashed right and left if I installed it first.

Any fixes to this problem?

Thanks all.
Last edited by AndyInNYC on Tue May 23, 2017 8:16 pm, edited 1 time in total.
User avatar
dizygotheca
Developer
Posts: 267
Joined: Wed Sep 03, 2014 9:02 am
Great Britain

Re: DVB Card - Can't open ...

Post by dizygotheca »

Code: Select all

$ grep video /etc/group
video:x:44:mythtv

$ ls -l /dev/dvb
total 0
drwxr-xr-x 2 root root 120 May 11 09:15 adapter0

$ ls -l /dev/dvb/adapter0/
total 0
crw-rw----+ 1 root video 212, 0 May 11 09:15 demux0
crw-rw----+ 1 root video 212, 1 May 11 09:15 dvr0
crw-rw----+ 1 root video 212, 3 May 11 09:15 frontend0
crw-rw----+ 1 root video 212, 2 May 11 09:15 net0
Are you sure the backend isn't still running and locking the cards ? The default/automatic 'Stop backend' commands are for UpStart and don't work on 16.04 until you modify them for SystemD.

After adding 'server' to the video group you need to log out/log in for it to take effect.

Yes you can add the ppa any time. I doubt it'll fix this problem though.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: DVB Card - Can't open ...

Post by AndyInNYC »

So, it would seem that Myth was running - even though the setup asks if you want to shut it down.

running the backend as root allowed me to watch shows (woo hoo). Is there a way to change whatever command starts the backend on boot up to run as root?

Andrew
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: DVB Card - Can't open ...

Post by bill6502 »

One solution:

Go into mythtv-setup (again) and look in General->Backend Control,
about the 7th page in. Fill in the Backend start and stop commands.

They may need sudo. If the command isn't allowed for user mythtv
in /etc/sudoers.d/mythtv, for example, it won't work. Be careful changing
the file as you can loose all sudo access if you mess up (been there
done that.) See the command visudo. Open two terminal windows
and type sudo -i in each, that way you can undo changes if you need
to. The file doesn't have to be named mythtv, but it just makes sense.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: DVB Card - Can't open ...

Post by AndyInNYC »

I've run a few tests:

1. If I just boot the machine and go into the client, all channels are Unavailable.
2. If I terminate mythbackend - sudo /etc/init.d/mythtv-backend stop, then myth stops
3. If I restart the backend with - sudo /etc/init.d/mythtvback-end start, then myth restarts, but the channels are unavailable
4. If I stop myth and then restart using - sudo mythbackend then 'poof' everything works

I have done the following to try to get mythtv upgraded:

Code: Select all

sudo usermod -aG sudo mythtv
On page 'whatever' of the General in mythtv-setup I set the startup command to be sudo mythbackend

This doesn't elevate when mythtv starts on boot - channels still appear as unavailable

I have added the line

Code: Select all

mythtv ALL=(ALL) ALL
to the sudoers via visudo
Rebooted - no go - channels still unavailable.

I still have sudo access, so no damage done.

I tried to use the GUI to change the mythtv user, but while the user exists, it doesn't show up/can't be changed via the GUI - I don't think it has login rights and therefore can't be elevated that way.

If I stop the program again and restart via sudo mythbackend I once again can watch TV via my Kodi frontend. Of course, once I close my putty window then Myth stops as well.

Hmm, so close - but not there.

Suggestions on what I'm doing wrong (seemingly Linux related vs. MythTV, but still a Myth problem since all the defaults won't work)? This is definitely looking more and more like a permissions problem focused solely on the DVB cards (hence the video unavailable, while the program runs).


Thanks again for all the help - I'm within striking distance (I hope).


Andrew
User avatar
pgbennett
Developer
Posts: 503
Joined: Mon Apr 27, 2015 5:41 pm
United States of America

Re: DVB Card - Can't open ...

Post by pgbennett »

Did you check what user mythbackend is running under? Run ps -ef and look through the list. Possibly it is running under some user other than mythtv or system, in which case add that user to the video group. If you are using the default setup from the ppa it should be running under mythtv.

One other thing - perhaps the video card is not up and running yet when mythtv starts. Try putting a delay into the startup, or for a test, just stop and start the backend. Run sudo systemctl stop mythtv-backend and sudo systemctl start mythtv-backend. If it works upon stopping and starting, the backend may be coming up too soon after boot.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: DVB Card - Can't open ...

Post by AndyInNYC »

Thanks for the reply.

ps -ef returns:

Code: Select all

mythtv    1758     1  0 22:37 ?        00:00:00 /usr/bin/mythbackend --quiet --syslog local7
starting and stopping using sudo systemctl made no difference.

I tried editing /etc/init.d/mythtv-backend and changing the line USER=mythtv to USER=root; this had no impact and the user was still mythtv upon a reboot. Changed it back so we would be on same starting point for your next clue/brread crumb.

ls -l /dev/dvb/adapter?/* returns:

Code: Select all

sudo ls -l /dev/dvb/adapter?/*
crw-rw----+ 1 root video 212, 0 May 12 22:47 /dev/dvb/adapter0/demux0
crw-rw----+ 1 root video 212, 1 May 12 22:47 /dev/dvb/adapter0/dvr0
crw-rw-rw-+ 1 root video 212, 3 May 12 22:47 /dev/dvb/adapter0/frontend0
crw-rw----+ 1 root video 212, 2 May 12 22:47 /dev/dvb/adapter0/net0
crw-rw----+ 1 root video 212, 5 May 12 22:47 /dev/dvb/adapter1/demux0
crw-rw----+ 1 root video 212, 6 May 12 22:47 /dev/dvb/adapter1/dvr0
crw-rw-rw-+ 1 root video 212, 4 May 12 22:47 /dev/dvb/adapter1/frontend0
crw-rw----+ 1 root video 212, 7 May 12 22:47 /dev/dvb/adapter1/net0
which appears to my untrained eye (root video) to be what it is supposed to be.

mythtv, server, root (all the users on the machine) are members of video

Removed the command to start mythtv from the General section - it starts up on its own.

Added the command back for myth startup as sudo /etc/init.d/mythtv-backend start - used both mythtv and root as the user in the file - no change.

If I run sudo mythtvbackend I can watch TV; otherwise, still no dice.


Andrew
User avatar
dizygotheca
Developer
Posts: 267
Joined: Wed Sep 03, 2014 9:02 am
Great Britain

Re: DVB Card - Can't open ...

Post by dizygotheca »

I tried editing /etc/init.d/mythtv-backend and changing the line USER=mythtv to USER=root; this had no impact and the user was still mythtv upon a reboot
Unless you've reconfigured it, 16.04 should be using Systemd https://www.mythtv.org/wiki/Systemd_myt ... figuration
Look for a mythbackend.service file in /etc/systemd/system/

Maybe it's linked somehow to UpStart (/etc/init.d/mythtv-backend) but I wonder if trying to use both is resulting in multiple backends running, causing the card contention. Some backend logs of failed & success states would be helpful.
Removed the command to start mythtv from the General section - it starts up on its own.
Those commands are only used when mythtv-setup tries to stop/restart the backend - your original problem.
At boot Systemd starts the backend on its own.

If you've installed 0.28.0 from the Ubuntu repositories I have a vague recollection of reported issues with the systemd service. Maybe updating using the 0.28/fixes PPA will help.
AndyInNYC
Junior
Posts: 27
Joined: Mon Mar 21, 2016 3:37 pm
United States of America

Re: DVB Card - Can't open ... (SOLVED)

Post by AndyInNYC »

OK,

There is a file 'mythtv-backend.service' in the /etc/systemd/system/multi-user.target.wants
I changed the user to root and added a sudo in the front of the Exec command. This caused mythtv not to load at all. removed the sudo command and rebooted.
Now it had user as root and the rest as defaults - BINGO!

So, Mythbackend is now running as root and correctly shows video to the front end.

Although i don't know why I need to run this as root versus mythtv as the rest of the world does, I'm happy (barring some new disaster) to call this one Solved.


Andrew
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: DVB Card - Can't open ...

Post by bill6502 »

Can't argue with success, but: the file under /etc/systemd/system/multi-user.target.wants
is most likely a symbolic link to a file with the same name under /lib/systemd/system.

If you change that, then if/when the distribution releases a new version of that file,
your changes will be erased. The proper way to make changes in the .service file
is to put a copy under /etc/systemd/system.

However the system starts the backend at boot is how you should too. If you run
mythbackend from the command line, then systemd won't know about it. To stop
it, use sudo systemctl stop mythtv-backend.service and replace stop with start to
start it. The same commands should be used in mythtv-setup.
Post Reply