Starting and configuring TVH as hts
Added by Steve Miller about 5 years ago
I have run TVH on a Pogoplug for a couple of years. It crashed recently and I upgraded the OS, Arch Linux. After that, TVH would not run. So I downloaded the source for 4.2.8 and rebuilt it again. The build and install went fine. However, I am stuck getting it started. I started and configured TVH with tvheadend -C. I setup the muxes, channels, users, etc. All that is fine. However, it is configured and running as a basic user "steve" aka me and in group user, because that is what I was logged in as when setting it up. I searched the forum for more details on initial startup and have not found the answer to proper startup.
1. How do I start as user hts to get the initial configuration?
2. Is it possible to move all the config from /home/steve/.hts back to the hts user? Or do I need to uninstall and re-install again?
3. What is required for systemctl to start TVH as the hts user? My old notes just have "systemctl start tvheadend", but that does not appear to be accurate.
A hint for the documentation would be a warning about what user starts tvheadend. In testing and attempts at troubleshooting, I started it from both basic user "steve" and from root. I now have three different .hts folders in three different locations on the drive. This makes for even more confusion and to where any of the data is. Fully my mistake for starting as a different user, but would be nice if the docs warned on this.
Thanks.
--- Steve
Replies (8)
RE: Starting and configuring TVH as hts - Added by saen acro about 5 years ago
tvheadend -h
yes you can move config but change ownership
build latest 4.3.xxxx
there is much more features
RE: Starting and configuring TVH as hts - Added by Steve Miller about 5 years ago
I believe the -h just displays the help screen. I did that, but the information did not help me. I tried the tvheadend -u hts to start as user hts. However, that seems to just revert back to running as the logged in user.
Searching the internet this morning I found:
https://www.systutorials.com/docs/linux/man/1-tvheadend/
I don't know if this documentation is correct or not. However, it has the following statement:
"If Tvheadend is started without the '-f' argument it will not daemonize nor change its primary userid/groupid. Rather it will run with the permissions granted to the user executing the binary."
If the above is true, then it would explain my difficulty as I am not using the -f option. I will try it later today when I am at home.
RE: Starting and configuring TVH as hts - Added by Joe User about 5 years ago
Yes, you can move or copy the config, but as saen says make sure you change ownership
chown -R hts:hts /home/hts/.hts
Starting tvheadend as user "steve" will not allow it to change to user "hts". So either switch user (su) to user hts before starting, or run as root with options "-u hts -g video".
RE: Starting and configuring TVH as hts - Added by Steve Miller about 5 years ago
Thank you for the tip to run as root. Over the weekend, I was using "sudo tvheadend -u hts -g video" and it still seemed to open it as user "steve" which is what I was logged in as. Since the system has a real root login, I logged in as root and ran "tvheadend -u hts -g video" and it worked!
I tried copying just the config file that I found under tvheadend, but it did not seem to bring over any of my setup. So, I just blindly copied the entire folder , its files and sub-folders. Then I changed the ownership and restarted tvheadend with the command string about. As tvheadend was starting, I noticed in the console messages that it was not finding the xmltv config as I had also configured that as user "steve". So, I copied that folder and its contents over and then again changed the ownership. For anyone else with a similar problem, below are the basic linux commands that I used. All were from from a root login.
It is still not running as a service, but since my wife wants a show recorded for tomorrow, that is a battle for another day. It is also issuing warnings and some spawn errors on startup, so what I did was not probably totally kosher.
ps aux | grep tvheadend
cp -r /home/steve/.hts/tvheadend/. /home/hts/.hts/tvheadend
chown -R hts:video /home/hts/.hts/tvheadend
cp -r /home/steve/.xmltv/. /home/hts/.xmltv
chown -R hts:video /home/hts/.xmltv
tvheadend -u hts -g video &
RE: Starting and configuring TVH as hts - Added by Steve Miller about 5 years ago
OK, I am my own worst enemy. After my recording failed because I configured it wrong. I decided to work on starting as a service. I killed tvheadend and then rebooted. Before doing anything, I checked whether it was already running and it was. Seems that the service was already setup by the installer. All my previous recordings were listed and my channels were listed. However, my EPG was blank. Thinking that it just needed time to scrap a new copy. Allowed it ten minutes or so, but it was still blank and refresh did not populate anything. I looked at the EPG grabber section of the GUI config and it did not have any of the Internal XMLTV grabbers listed. I did a status of the tvheadend service and got the command line of
/usr/bin/tvheadend -f -p /var/run/tvheadend.pid -u hts -g video
Stopping and restarting the tvheadend service did not bring back the grabbers. However, if I stop the service and then paste that exact command line above into a console prompt then it has all the Internal XMLTV grabbers listed. So, there is something different when systemctl runs this command and when I do it manually. The entire contents of tvheadend.service is pasted below. Do I have to add a path or something to this?
Thanks.
--- Steve
[Unit]
Description=Tvheadend - a TV streaming server and DVR
After=syslog.target network.target auditd.service
[Service]
ExecStart=/usr/bin/tvheadend -f -p /var/run/tvheadend.pid -u hts -g video
PIDFile=/var/run/tvheadend.pid
Type=forking
Restart=on-failure
RestartSec=54s
[Install]
WantedBy=multi-user.target
RE: Starting and configuring TVH as hts - Added by Steve Miller about 5 years ago
No luck on getting the Program Guide working. My guess is that somehow the tvheadend.service does not know the correct path. The perl stuff is in my path
PATH=$PATH:/usr/lib/java/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/vendor_perl:/usr/bin/core_perl
If I log the messages from tvheadend from starting as a service and the starting from a console prompt, I see the difference below. The first set is the running as service and the second is the console.
2019-09-23 19:03:40.360 [ INFO]:epggrab: module pyepg created
2019-09-23 19:03:40.363 [ INFO]:epggrab: module xmltv created
2019-09-23 19:03:40.370 [ DEBUG]:xmltv: using internal grab search
2019-10-31 21:10:29.808 [ INFO]:epggrab: module pyepg created
2019-10-31 21:10:29.810 [ INFO]:epggrab: module xmltv created
2019-10-31 21:10:29.827 [ INFO]:spawn: Executing "/usr/bin/vendor_perl/tv_find_grabbers"
The first set implies that tvheadend is searching for internal grabbers and then finding none. The second one finds them in the path and starts executing them.
I don't know why the path environments would be different. I tried several ways to include the path into the tvheadend.service file, but none were successful.
Any ideas what is wrong?
Thanks.
RE: Starting and configuring TVH as hts - Added by Joe User about 5 years ago
Did you see this?
https://tvheadend.org/boards/12/topics/16105
RE: Starting and configuring TVH as hts - Added by Steve Miller about 5 years ago
Thank you Joe for the link. I had not seen that. The link confirmed that the issue is Arch Linux. Apparently the environment path is not passed to systemd. I did not follow how the other users created hard links as a workaround, but I did get it to work finally. To the tvheadend.service file I added:
Environment=PATH=:/usr/lib/java/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/vendor_perl:/usr/bin/core_perl
to the [Service] section on a separate line before the ExecStart command. That complete path is probably not required as I probably only need the perl folders. Anyone else with this problem should use their actual path variable and not my example above in case your perl stuff is in a different folder.