Kodi

From Gentoo Wiki
(Redirected from XBMC)
Jump to: navigation, search

Kodi (formerly XBMC) is a media center application.

Warning
The upstream recently renamed XBMC to Kodi. If you are using a version older than 14.0 you will need to use the old name.

Start on boot

Using OpenRC

First create the kodi user

root #useradd -m -G audio,cdrom,video,cdrw,usb,users kodi

Then define the Kodi init.d file with the following contents

FILE /etc/init.d/kodi
#!/sbin/runscript
# Released under the 2-clause BSD license.
 
description="Start and stop Kodi"
 
depend()
{
	need net
}
 
start()
{
        ebegin "Starting Kodi"
        start-stop-daemon --start -u ${KODI_USER:-kodi} --background --pidfile /var/run/xodi.pid --make-pidfile --exec /usr/bin/xinit -- /usr/bin/kodi-standalone ${KODI_OPTS} -- :0
        eend $?
}
 
stop()
{
        ebegin "Stopping Kodi"
        start-stop-daemon --stop --pidfile /var/run/kodi.pid
        eend $?
}

Set the appropriate permissions

root #chmod +x /etc/init.d/kodi

And tell openrc to start it on boot

root #rc-update add kodi default

Using inittab

This is based on the way the mythtv ebuilds enable the autostart of the mythtv frontend.

First create the kodi user

root #useradd -m -G audio,cdrom,video,cdrw,usb,users kodi

Define an xinitrc file in kodi's home

FILE /home/kodi/.xinitrc
# .xinitrc
[ -x /usr/bin/nvidia-settings ] && /usr/bin/nvidia-settings -l
/usr/bin/xset s noblank
/usr/bin/xset s off
/usr/bin/xset -dpms
/usr/bin/evilwm &
exec /usr/bin/kodi

Then create the login scripts

FILE /home/kodi/.bash_profile
/home/kodi/.bash_profile
# .bash_profile
case "`tty`" in
        *tty9) startx; logout ;;
esac

Finally append an inittab entry which does the autologin

FILE /etc/inittab
# Start Kodi
c9:2345:respawn:/sbin/mingetty --autologin kodi tty9

Shutdown

Allow the kodi user to issue an shutdown via polkit, resulting in a shutdown option in the Kodi menu:

FILE /etc/polkit-1/rules.d/60-kodi.rules
polkit.addRule(function(action, subject) {
        if (( (action.id.indexOf("org.freedesktop.udisks.") == 0) || (action.id.indexOf("org.freedesktop.upower.")== 0) || (action.id.indexOf("org.freedesktop.consolekit.")== 0) ) &&
        subject.user=="kodi") {
        return polkit.Result.YES;
        }
});

Note: ensure you have the udev USE flag set for shutdown to work

Running on Gentoo Hardened

Running Kodi on a Hardened Gentoo installation is possible. To avoid grsecurity interfering with network connectivity, the CONFIG_GRKERNSEC_PROC_USER kernel option must not be enabled.

Should you require a restricted /proc filesystem, use CONFIG_GRKERNSEC_PROC_USERGROUP and set GRKERNSEC_PROC_GID to the ID of a group that the user running Kodi is a member of.

External resources