Project

General

Profile

User hts not created during setup

Added by J Falcon over 1 year ago

Somehow, I installed TVH and the hts user was not created. I didn't notice, since everything is working, until receiving permission denied messages in the log when I attempt to grab xmltv.

I've installed and had TVH running for years on various Ubuntu setups. This time around I went with Manjaro. Installed tvheadend-git from AUR. It was easy.

I've tried manually creating the hts user, adding to video group, applying chmod on the directories for the zap2epg scripts... No luck.

My question is, can I fix this permission problem or do I need to uninstall and start again?

[Solved]
The tvheadend-git AUR script installs TVH to a system user, no home folder. Moved my tv grab files/scripts to a newly created directory /var/lib/tvheadend/zap2epg/ and the permission issue is resolved.


Replies (14)

RE: User hts not created during setup - Added by J Falcon over 1 year ago

Here is a sample from the log with the permission error. My research indicates that because TVH is running outside of the hts user there are no permissions assigned to allow it access to the grab script files.

Loglevel debug: enabled
2023-02-23 23:38:28.375 xmltv: /usr/bin/tv_grab_zap2epg: grab /usr/bin/tv_grab_zap2epg
2023-02-23 23:38:28.383 spawn: Executing "/usr/bin/tv_grab_zap2epg"
2023-02-23 23:38:28.497 spawn: /usr/bin/tv_grab_zap2epg: line 27: cd: /home/USER/.kodi/userdata/addon_data/script.module.zap2epg: Permission denied
2023-02-23 23:38:28.545 spawn: python: can't open file '/home/USER/.kodi/addons/script.module.zap2epg/zap2epg.py': [Errno 13] Permission denied
2023-02-23 23:38:28.555 spawn: cat: /home/USER/.kodi/userdata/addon_data/script.module.zap2epg/xmltv.xml: Permission denied
2023-02-23 23:38:28.556 xmltv: /usr/bin/tv_grab_zap2epg: no output detected
2023-02-23 23:38:28.556 xmltv: /usr/bin/tv_grab_zap2epg: grab returned no data

RE: User hts not created during setup - Added by saen acro over 1 year ago

Post result of

ps aux | grep tvheadend
ls -al /home/USER/.kodi/userdata/addon_data/
ls -al /home/USER/.kodi/addons/script.module.zap2epg/

RE: User hts not created during setup - Added by J Falcon over 1 year ago

ps aux | grep tvheadend
tvheade+     402  194  1.4 1406212 115636 ?      Ssl  Feb22 4199:27 /usr/bin/tvheadend -c /etc/tvheadend -f -p /run/tvheadend/tvheadend.pid -C

ls -al /home/USER/.kodi/userdata/addon_data/
total 0
drwxrwsrwx 1 USER USER 182 Feb 17 15:39 .
drwxrwxrwx 1 USER USER 308 Feb 22 11:07 ..
drwxrwxrwx 1 USER USER  24 Feb 17 15:39 metadata.tvshows.themoviedb.org.python
drwxrwxrwx 1 USER USER 116 Feb 19 00:25 pvr.hts
drwxrwxrwx 1 USER USER 148 Feb 19 00:43 script.module.zap2epg
drwxrwxrwx 1 USER USER  24 Feb 13 23:42 skin.estuary
drwxrwxrwx 1 USER USER  24 Feb 17 15:30 weather.multi
ls -al /home/USER/.kodi/addons/script.module.zap2epg/
total 112
drwxrwsrwx 1 USER USER   186 Feb 17 23:29 .
drwxr-xr-x 1 USER USER   812 Feb 24 08:44 ..
-rwxrwxrwx 1 USER USER  2786 Feb 15 23:32 addon.xml
drwxrwxrwx 1 USER USER    30 Feb 15 23:32 bin
-rwxrwxrwx 1 USER USER  1914 Feb 15 23:32 changelog.txt
-rwxrwxrwx 1 USER USER 12988 Feb 17 23:29 default.py
-rwxrwxrwx 1 USER USER 35127 Feb 15 23:32 LICENSE
drwxrwxrwx 1 USER USER    58 Feb 15 23:32 __pycache__
-rwxrwxrwx 1 USER USER  1109 Feb 15 23:32 README.md
drwxrwxrwx 1 USER USER    62 Feb 15 23:32 resources
-rwxrwxrwx 1 USER USER  1523 Feb 15 23:32 settings.xml
-rwxrwxrwx 1 USER USER 43733 Feb 22 17:31 zap2epg.py

RE: User hts not created during setup - Added by saen acro over 1 year ago

TVH is not started with

-u hts -g video

RE: User hts not created during setup - Added by J Falcon over 1 year ago

I assume that is part of my problem. This has never happened in my previous installs.

Is there a way to adjust it's permission as is or add it to user/group post install?

RE: User hts not created during setup - Added by saen acro over 1 year ago

hts user was created by debian installer script only.

RE: User hts not created during setup - Added by Dave H over 1 year ago

I don't understand. Do you actually have a user called USER or is that to obfuscate the actual user for some reason?
It seems likely that TVH is running as user 'tvheadend'. That is presumably part of the installation on your system. How is TVH started? How was the user created? Why was it not started as described on https://wiki.archlinux.org/title/Tvheadend ?

RE: User hts not created during setup - Added by J Falcon over 1 year ago

Yes, USER is my user alias.

The first time I launched TVH after install was as a daemon. When it didn't start automatically on reboot, I used the enable and start tvheadend.service as indicated in the wiki. I had to completely reconfigure in the web portal. Now it auto starts on reboot.
I did not create a user during install. Octopi ran the script. Perhaps that was my mistake? Should I start over and edit something in the PKGBUILD?

# Maintainer: Francois Menning <[email protected]>
# Contributor: Dan Ziemba <[email protected]>
# Contributor: Benjamin Hedrich <kiwisauce (a) pagenotfound (dot) de>

_gitname='tvheadend-git'
pkgname=tvheadend-git
pkgver=4.3.r2028.g1c65e8b0f
pkgrel=1
pkgdesc="TV streaming server for Linux" 
arch=('i686' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64')
url="https://tvheadend.org/" 
license=('GPL3')
depends=(
  'avahi'
  'ffmpeg4.4'
  'libavresample'
  'libdvbcsa'
  'libfdk-aac'
  'libhdhomerun'
  'libogg'
  'libtheora'
  'libvorbis'
  'libvpx'
  'openssl'
  'opus'
  'pcre2'
  'pngquant'
  'uriparser'
  'x264'
  'x265'
)
makedepends=(
  'git'
  'python'
)
optdepends=(
  'xmltv: For an alternative source of programme listings'
)
options=('!strip' 'emptydirs')
provides=('tvheadend')
conflicts=('tvheadend')
source=(
  "${_gitname}::git+https://github.com/tvheadend/tvheadend.git" 
  tvheadend.service
  tmpfile.conf
  user.conf
  0001-use-ffmpeg4.4.patch
)
sha512sums=('SKIP'
            'd29662ee47f2d0da98d444819f730a8c487999454d60d7397b0f67068300ab5111ffce18befc9fdef5ff8fa1925213716837ea44808fb934197e4a56f98de8a7'
            '1080c8a2530d1f16ab5304cdd81c9c9da23b281e44a4874f4921905c843d876831214af481f9be91a74291ed4a6a10684dbdfb8f926b51bbb6895b92d493b201'
            '5e0475cfe1f915bd3269ba3e9e0ca6cc7e492988bfd4f1feafcbbd3e8b0276c228f0b08a4116f3213d12c0ea940eff0dc71601a6e6ddcda934964cf51a665539'
            'f381843e870723bffe34648e6427a5bbfb85076f59b2def1e89b58bc68db93f06dbd6fe20b508bb72daecf0e832094beae769425c121c632a9d017edd00b8575')

pkgver() {
  cd "${srcdir}/${_gitname}" 
  git describe --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd "${srcdir}/${_gitname}" 
  patch -Np1 -i ../0001-use-ffmpeg4.4.patch
}

build() {
  cd "${srcdir}/${_gitname}" 

  # Work-around for GCC 10
  export CFLAGS="$CFLAGS -Wno-error=array-bounds -Wno-error=address" 

  ./configure \
    --prefix=/usr \
    --datadir=/var/lib \
    --mandir=/usr/share/man/man1 \
    --python=python3 \
    --enable-avahi \
    --enable-zlib \
    --enable-pngquant \
    --enable-libav \
    --disable-ffmpeg_static --enable-ffmpeg \
    --disable-libx264_static --enable-libx264 \
    --disable-libx265_static --enable-libx265 \
    --disable-libvpx_static --enable-libvpx \
    --disable-libogg_static --enable-libogg \
    --disable-libtheora_static --enable-libtheora \
    --disable-libvorbis_static --enable-libvorbis \
    --disable-libfdkaac_static --enable-libfdkaac \
    --disable-libopus_static --enable-libopus \
    --disable-hdhomerun_static --enable-hdhomerun_client

  make
}

package() {
  cd "${srcdir}/${_gitname}" 

  make DESTDIR="$pkgdir/" install

  install -Dm 644 "${srcdir}/tvheadend.service" -t "${pkgdir}/usr/lib/systemd/system" 
  install -Dm 644 "${srcdir}/user.conf" "${pkgdir}/usr/lib/sysusers.d/tvheadend.conf" 
  install -Dm 644 "${srcdir}/tmpfile.conf" "${pkgdir}/usr/lib/tmpfiles.d/tvheadend.conf" 
}

RE: User hts not created during setup - Added by Dave H over 1 year ago

Sorry, J Falcon, your answer just confuses me further. It would help me if you gave straight answers to my questions. I don't know what you mean by most of the terms in your answer.

RE: User hts not created during setup - Added by J Falcon over 1 year ago

Jonas Lang wrote:

Try this and see if it works https://tvheadend.org/boards/4/topics/16388

Thanks for the link. Running as su tvheadend -f -u hts -g video does start TVH. There seems to be 2 instances running aftwards, the .service and the one from this command.

ps aux | grep tvheadend
bin        17064  5.0  0.3 974964 28876 ?        Ssl  11:32   0:00 tvheadend -f -u hts -g video
root       17104  0.0  0.0   6572  2556 pts/2    S+   11:33   0:00 grep --colour=auto tvheadend

Dave H wrote:

I don't understand. Do you actually have a user called USER or is that to obfuscate the actual user for some reason?
It seems likely that TVH is running as user 'tvheadend'. That is presumably part of the installation on your system. How is TVH started? How was the user created? Why was it not started as described on https://wiki.archlinux.org/title/Tvheadend ?

Looking closer at the arch wiki, I skipped a step and didn't add the override here. /etc/systemd/system/tvheadend.service.d/override.conf
When I do add the lines listed, the service fails to start. If I # out all the lines in that file, it will start.
I tried starting from scratch and following the arc wiki. Uninstalled tvheadend-git, deleting the hts user userdel -r hts and group groupdel hts and rebooted.
Added the override.conf with the exact text from the wiki. Then enable/start the service as su.

systemctl enable tvheadend.service
systemctl start tvheadend.service

The override seems to cause the service start to fail.

systemctl status tvheadend.service
× tvheadend.service - Tvheadend - a TV streaming server and DVR
     Loaded: loaded (/usr/lib/systemd/system/tvheadend.service; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/tvheadend.service.d
             └─override.conf
     Active: failed (Result: exit-code) since Sat 2023-02-25 11:21:00 EST; 32min ago
    Process: 16884 ExecStart=/usr/bin/tvheadend -f -p /var/run/tvheadend.pid -u hts -g video --firstrun (code=exited, status=1/FAILURE)
        CPU: 63ms

Feb 25 11:21:00 PC1 systemd[1]: tvheadend.service: Scheduled restart job, restart counter is at 5.
Feb 25 11:21:00 PC1 systemd[1]: Stopped Tvheadend - a TV streaming server and DVR.
Feb 25 11:21:00 PC1 systemd[1]: tvheadend.service: Start request repeated too quickly.
Feb 25 11:21:00 PC1 systemd[1]: tvheadend.service: Failed with result 'exit-code'.
Feb 25 11:21:00 PC1 systemd[1]: Failed to start Tvheadend - a TV streaming server and DVR.

I'm thinking that the override.conf needs to be tweaked.
Or, since the only issue I have is running the tv grab, perhaps I can simply move that script and output xml to another directory that the service can access?

Apologies for the long post. I wanted to answer both of you as completely as possible. Thank you for the assistance!

RE: User hts not created during setup - Added by Jonas Lang over 1 year ago

That link I referenced is 8 years old. Things have probably moved on since then.

I did see this on a search https://forum.manjaro.org/t/raspberry-pi4-kodi-and-pvr-hts/27910
That was a combined Kodi/TVH install. I did notice reference to a Snapcraft TVH install too but not to everyone’s liking.

Not sure what hardware you are running on but might be worth trying to build TVH yourself. Plenty of instructions here to achieve that. Might also be worth posting on the Manjaro forum too.

RE: User hts not created during setup - Added by Dave H over 1 year ago

J Falcon wrote:

Jonas Lang wrote:

Try this and see if it works https://tvheadend.org/boards/4/topics/16388

Thanks for the link. Running as su tvheadend -f -u hts -g video does start TVH. There seems to be 2 instances running aftwards, the .service and the one from this command.
[...]

There's only one instance shown there - the other line is the grep command. It would be worthwhile learning how to interpret the output of commands like ps.
Also, tvh is shown running there as user 'bin' so either there's something very strange with how your system is set up or you didn't start it how you said you did.

Dave H wrote:

I don't understand. Do you actually have a user called USER or is that to obfuscate the actual user for some reason?
It seems likely that TVH is running as user 'tvheadend'. That is presumably part of the installation on your system. How is TVH started? How was the user created? Why was it not started as described on https://wiki.archlinux.org/title/Tvheadend ?

Looking closer at the arch wiki, I skipped a step and didn't add the override here. /etc/systemd/system/tvheadend.service.d/override.conf

Well maybe that accounts for why there's no hts user then! :)

When I do add the lines listed, the service fails to start. If I # out all the lines in that file, it will start.

So when it fails what error messages are there? e.g. in the journal?

I tried starting from scratch and following the arc wiki. Uninstalled tvheadend-git, deleting the hts user userdel -r hts and group groupdel hts and rebooted.
Added the override.conf with the exact text from the wiki. Then enable/start the service as su.
[...]

The override seems to cause the service start to fail.
[...]

You did read the bit in the wiki page about installations from AUR behaving differently? Please post the contents of the tvheadend.service file.

I'm thinking that the override.conf needs to be tweaked.
Or, since the only issue I have is running the tv grab, perhaps I can simply move that script and output xml to another directory that the service can access?

Apologies for the long post. I wanted to answer both of you as completely as possible. Thank you for the assistance!

RE: User hts not created during setup - Added by J Falcon over 1 year ago

Good suggestion. I will post in the Manjaro forums.

Looking at the maintainer's notes, they deliberately changed where and how tvh runs.

TVHeadend will be installed to /var/lib/tvheadend instead of /usr/share/tvheadend
Package will create the system user tvheadend (member of group video) with config files stored in /etc/tvheadend, it will not use a home directory anymore.
By using sysusers.d and tmpfiles.d permissions should be easier to manage.
tvheadend.service now includes -C by default.
Added some missing deps

So I su and copied the files/directories to a newly created directory, /var/lib/tvheadend/zap2epg/ and edited the zap2epg file to point to this new directory.
It shows success in the log!
2023-02-25 14:47:56.003 spawn: Executing "/usr/bin/tv_grab_zap2epg"
2023-02-25 14:47:56.100 spawn: Traceback (most recent call last):
2023-02-25 14:47:56.100 spawn: File "/var/lib/tvheadend/zap2epg/script.module.zap2epg/zap2epg.py", line 813, in
2023-02-25 14:47:56.101 spawn: logging.basicConfig(filename=log, filemode='w', format='%(asctime)s %(message)s', datefmt='%Y/%m/%d %H:%M:%S', level=logging.DEBUG)
2023-02-25 14:47:56.101 spawn: File "/usr/lib/python3.10/logging/__init__.py", line 2040, in basicConfig
2023-02-25 14:47:56.101 spawn: h = FileHandler(filename, mode,
2023-02-25 14:47:56.101 spawn: File "/usr/lib/python3.10/logging/__init__.py", line 1169, in __init__
2023-02-25 14:47:56.101 spawn: StreamHandler.__init__(self, self._open())
2023-02-25 14:47:56.101 spawn: File "/usr/lib/python3.10/logging/__init__.py", line 1201, in _open
2023-02-25 14:47:56.102 spawn: return open_func(self.baseFilename, self.mode,
2023-02-25 14:47:56.102 spawn: PermissionError: [Errno 13] Permission denied: '/var/lib/tvheadend/zap2epg/script.module.zap2epg/zap2epg.log'
2023-02-25 14:47:56.227 xmltv: /usr/bin/tv_grab_zap2epg: grab took 0 seconds
2023-02-25 14:47:56.922 xmltv: /usr/bin/tv_grab_zap2epg: parse took 0 seconds
2023-02-25 14:47:56.922 xmltv: /usr/bin/tv_grab_zap2epg: channels tot= 69 new= 0 mod= 0
2023-02-25 14:47:56.922 xmltv: /usr/bin/tv_grab_zap2epg: brands tot= 0 new= 0 mod= 0
2023-02-25 14:47:56.922 xmltv: /usr/bin/tv_grab_zap2epg: seasons tot=13193 new= 1364 mod=11829
2023-02-25 14:47:56.922 xmltv: /usr/bin/tv_grab_zap2epg: episodes tot= 8399 new= 963 mod= 7436
2023-02-25 14:47:56.922 xmltv: /usr/bin/tv_grab_zap2epg: broadcasts tot=13568 new= 1358 mod= 2131
2023-02-25 14:47:56.922 xmltv: /usr/bin/tv_grab_zap2epg: scheduling save epg timer

There is only 1 permission message now about writing to the log that chmod won't solve. I'll miss having a log but I'm going to turn the other way and ignore it.
Oddly, the internal grabber is trying to run every 2 minutes, instead of the default cron setting. Topic for another day.

    (1-14/14)