Solved kodi service (create user problem)
#1
Hi,

I'm trying to follow the guide at:

https://www.smarthomebeginner.com/ubuntu...u-systems/

Part of the guide tells me that I need to create a user kodi. The following block of code to run in a terminal is
given (I have copied the code exactly as it is shown on the aforementioned website):

useradd kodi -u 420 -g kodi -G audio,video,network,optical \
-d /var/lib/kodi -s /usr/bin/nologin kodi
passwd -l kodi > /dev/null
mkdir /var/lib/kodi/.kodi
chown -R kodi:kodi /var/lib/kodi/.kodi

I assume this should be multiple commands. But what are they? I'm getting stuck on the first one! I thought the commands were:

$ useradd kodi -u 420 -g kodi -G audio,video,network,optical \ -d /var/lib/kodi -s /usr/bin/nologin kodi

$ passwd -l kodi > /dev/null

$ mkdir /var/lib/kodi/.kodi

$ chown -R kodi:kodi /var/lib/kodi/.kodi

But the first one gives an error. So what should it be?
Reply
#2
Hi.

How did you install Ubuntu to begin with and how are you accessing the terminal. Are you accessing remotely, eg via ssh

I ask because I used the server iso (for minimal packages, no desktop) and my user created during install requires me to use super user privilege's for most operations in the command line.

Happy to share my notes if useful?
Reply
#3
Ah yes, sorry, I use ssh and should have put sudo in front of the commands. So my guesses for the commands are now:


$ sudo useradd kodi -u 420 -g kodi -G audio,video,network,optical \ -d /var/lib/kodi -s /usr/bin/nologin kodi

$ sudo passwd -l kodi > /dev/null

$ sudo mkdir /var/lib/kodi/.kodi

$ sudo chown -R kodi:kodi /var/lib/kodi/.kodi

the first one still does not work! I get an error that group kodi does not exist which is normal. Usually I would create a new user as follows:

$ sudo useradd kodi

This would create the user AND the group kodi. However what do I do to duplicate the original commands? I thought of the following

$ sudo useradd kodi
$ sudo usermod -a -G audio,video,network,optical kodi

but what about the other parts in the origianl command:

-u 420 -g kodi -G audio,video,network,optical \ -d /var/lib/kodi -s /usr/bin/nologin kodi

what do they do?
Reply
#4
-u is the user ID of the account, -g is the group, -G is a list of supplementary groups to add the user to, -d is the home directory of the user, -s is the shell to use.

You can find all that out for yourself by putting useradd --help.  In fact, you can put that (or man useradd) for most commands.
Learning Linux the hard way !!
Reply
#5
If this is a dedicated Kodi machine, which it seems I think all of that is pretty much unnecessary.
Code:
adduser kodi
passwd -d kodi
systemctl enable kodi.service
systemctl start kodi.service

And done. Most of that other stuff that looks like gibberish to you is stuff that the majority of people don't need for any logical reason. Just my opinion. Like the guide, most of it is their opinion. Since you don't have any other user's here what difference does it make what the uid is, or where kodi's home directory is. It doesn't. I don't even think the group membership's are necessary. Mine works just fine with no groups at all on it. But to each their own I guess.

*EDIT* unless someone can correct my thinking as to why it is important to do it the above way? i'd be happy to learn the reasons.

I've come to find that guides are just that, guides. Not usually meant to be taken letter for letter. Can be hard to tell which is which sometimes though, especially when you are totally new to doing any of it like this.
Reply
#6
OK, but the problem with that is that the github site that hosts the project says that:

Note that the kodi user's home directory is /var/lib/kodi/ in this example, NOT /home/kodi/ like a regular user.

Anyway, which ever way I try and set it up I get the same problem. I create the user kodi (one way or another)

Then I run

$ sudo systemctl start kodi.service

I get the following output from

$ ps aux | grep kodi

kodi      6624  0.0  0.0  15924   888 tty1     Ss+  13:56   0:00 /usr/bin/xinit /usr/bin/kodi-standalone -- :0 -nolisten tcp vt1
kodi      6625  0.6  0.0  45400  5256 ?        Ss   13:56   0:00 /lib/systemd/systemd --user
kodi      6627  0.0  0.0 163896  2440 ?        S    13:56   0:00 (sd-pam)
kodi      6630  0.0  0.0 186580  2528 tty1     S+   13:56   0:00 (sd-pam
kodi      6631  0.0  0.0      0     0 tty1     Z    13:56   0:00 [Xorg] <defunct>
userX       6642  0.0  0.0  14228   936 pts/17   S+   13:56   0:00 grep --color=auto kodi


And after about 10 seconds I get

$ ps aux | grep kodi

userX       6731  0.0  0.0  14228   944 pts/17   S+   13:59   0:00 grep --color=auto kodi

and

$ sudo systemctl status kodi.service

shows

kodi.service - Kodi standalone (X11)
   Loaded: loaded (/usr/lib/systemd/system/kodi.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2020-04-07 13:57:00 CEST; 3min 18s ago
  Process: 6624 ExecStart=/usr/bin/xinit /usr/bin/kodi-standalone -- :0 -nolisten tcp vt1 (code=exited, status=1/FAILURE)
 Main PID: 6624 (code=exited, status=1/FAILURE)

Apr 07 13:56:45 acg-NUC7PJYH systemd[1]: Started Kodi standalone (X11).
Apr 07 13:56:45 acg-NUC7PJYH systemd[6624]: pam_unix(loginConfusedession): session opened for user kodi by (uid=0)
Apr 07 13:57:00 acg-NUC7PJYH systemd[1]: kodi.service: Main process exited, code=exited, status=1/FAILURE
Apr 07 13:57:00 acg-NUC7PJYH systemd[1]: kodi.service: Unit entered failed state.
Apr 07 13:57:00 acg-NUC7PJYH systemd[1]: kodi.service: Failed with result 'exit-code'.
Reply
#7
I should also have mentioned that this is all running on Ubuntu and not a dedicated Kodi install. I'm trying to run kodi under a different user to the one I am logged in under Ubuntu. Of course, what I am trying to use this kodi service for might be completely wrong!!
Reply
#8
Shall we back-track a little ?

What is it exactly that you want to achieve with Ubuntu and Kodi ?  Perhaps defining the what will explain it, but if not, why do you want to do this ?
Learning Linux the hard way !!
Reply
#9
Ah yes, well, basically I want to be able to run kodi with user1 in Ubuntu, where I have logged into Ubuntu as user2. I know that I can run kodi from Ubuntu for a single user. However, I cannot find anything on the web that deals with my specific requirement.
Reply
#10
OK, but why ?  As I type on my Ubuntu desktop, Kodi is running on my TV but as the same user.  It doesn't interfere with my desktop or anything I do and although I could set it up to run under a different user I see no need to do so.  So I'm just wondering what advantage or difference you expect by having Kodi run as a different user ?
Learning Linux the hard way !!
Reply
#11
OK, well, put simply, split tunneling!

I want to run Ubuntu through my ISP's IP address and kodi through my VPN's IP address. I have set up split tunneling so the user vpn has all traffic go through the VPN and everything else through my usual IP address.
Reply
#12
I have posted a explanation of my problem on the forum in the offtopic section as I know kodi does not answer questions regarding VPN's in the other sections.
Reply
#13
Hmmm, well leaving that aside, why don't you just create another user (with access to the required groups), log in as that user, start Kodi and then switch to the other user without logging out ?  Will that not work ?
Learning Linux the hard way !!
Reply
#14
Smile 
Oh, to be able to think about the simple solution! ... Many many thanks, my system now works just how I wanted. Big Grin
Reply
#15
Thread marked solved.
Reply

Logout Mark Read Team Forum Stats Members Help
kodi service (create user problem)0