Skip to content

Instantly share code, notes, and snippets.

@ammgws
Last active January 19, 2018 13:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ammgws/8a90c87b92a708116ef05b82a4fb624e to your computer and use it in GitHub Desktop.
Save ammgws/8a90c87b92a708116ef05b82a4fb624e to your computer and use it in GitHub Desktop.
Notes on how I setup HTPC for future reference

1. Preparation / OS Install

  • Create liveusb using Ubuntu mini.iso dd bs=4M if=/home/user/Downloads/mini.iso of=/dev/sdf status=progress; and sync in fish shell

  • During install will be prompted for what to install: choose xubuntu minimal and openssh server

  • This time left just one disk (8TB) in the case, and used LVM when partitioning: root given 15gb, data partition given the rest (set recovery-blocks to 1% and inode to largest size since this is just a media partition)

2. Creating a user with limited privileges for Kodi

Kodi will be run by a user with limited privileges. This is for security reasons as we will setup the user to login automatically with no password. The limited user will have restricted access to the OS (e.g. it will not be able to install programs system wide or change security settings).

Create a limited user account kodi with a disabled password:
NOTE: Use sudo su - kodi to login as kodi user when SSH'd in as another user.

sudo adduser --disabled-password --gecos "" kodi
  • Make the user able to login without a password:
sudo usermod --append --groups nopasswdlogin kodi
  • Gives the limited user user access to the video devices (video), connected external devices (plugdev), controller and joystick input (input) and connected wireless and Ethernet networks (netdev).
sudo usermod --append --groups video,plugdev,users,input,netdev kodi

3. Install Kodi

sudo apt-add-repository ppa:team-xbmc/ppa
sudo apt update
sudo apt install kodi

4. Set Kodi to autostart on boot/login

Create systemd service in /etc/systemd/system/
kodi.service

- [Unit]
- Description=Starts instance of Kodi using xinit
- After=systemd-user-sessions.service network.target sound.target mysqld.service
- Conflicts=getty@tty1.service

- [Service]
- User=kodi
- Group=kodi
- PAMName=login
- TTYPath=/dev/tty1
- ExecStart=/usr/bin/xinit /usr/bin/kodi-standalone -- :0 -nolisten tcp vt1
- Restart=on-abort
- StandardInput=tty

- [Install]
- WantedBy=multi-user.target
  • Couldn't get the above systemd script to work, but I think it should work if rewritten as a user service.
  • Anyway, decided to use lightdm autologin instead.
  • pam-service line is needed for passwordless login.
  • lightdm will run the session kodi (/usr/share/xsessions/kodi.desktop), which will then start kodi-standalone /etc/lightdm/lightdm.conf
[Seat:*]
pam-service=lightdm-autologin
autologin-user=kodi
autologin-user-timeout=0
autologin-session=kodi

Bonus: Add splashscreen from the discontinued Kodibuntu distro (from here)

wget -O plymouth-theme-kodi-animated-logo-master.zip https://github.com/solbero/plymouth-theme-kodi-animated-logo/archive/master.zip
unzip plymouth-theme-kodi-animated-logo-master.zip
cd plymouth-theme-kodi-animated-logo-master
sudo apt install fakeroot
chmod +x build.sh
./build.sh
sudo dpkg -i plymouth-theme-kodi-animated-logo.deb

Bonus 2: Install fish to make life easier

sudo apt-add-repository ppa:fish-shell/release-2
sudo apt update
sudo apt install fish
whereis fish
chsh --shell /path/to/fish  # for current user
sudo usermod --shell /path/to/fish kodi  # for kodi user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment