HOW-TO:Autostart Kodi for Linux

How to automatically start up in Kodi using various Linux distributions.

Upstart init script
Create a   with following contents.

You may have to edit   and replace the last line that says:

to

Kodi will now auto-start on boot and restart/respawn if killed or crashed.

Modify the inittab
This was tested on Arch Linux.

To automatically start xbmc on your system, do the following:

First you need to make some changes to. Comment out (add a #) to this line:

id:3:initdefault

to


 * id:3:initdefault

and uncomment

id:5:initdefault

Then add this line to the bottom:

x:5:wait:login -f  /dev/tty7

Using wait instead of respawn means that you can exit out of xbmc into the console.


 * NOTE*: This is a security hole as it autologins a dedicated xbmc user without asking for a password!

Now that we have the user logged in we need it to auto start XBMC. In  add the following to the end of the file (after removing/commenting any other exec lines that start a windowmanager):

exec ck-launch-session xbmc

Add this line to your

$(tty) = "/dev/tty7" && exec startx /dev/null

And create a hushlogin file to suppress login messages.

touch ~/.hushlogin

Lastly, for the magic sauce that makes this work, add dbus to your daemons in.

DAEMONS=(... dbus ...)

You're finished. Next time you reboot you should be greeted with XBMC.

Add a new init script
This method works well under Debian. The current configuration is a HTPC running Debian Squeeze, with no window manager installed. The main goal here is to start an Xserver only for Kodi. It allows also to specify which user will start / own the Kodi process. This method will not work if you have a window manager installed (however, it should not be hard to modify the script to suit your needs)


 * Create a new script under /etc/init.d/. Call it kodi
 * Change the rights, in order to allow it to be executable.
 * 1) chmod a+x /etc/init.d/kodi
 * copy the code under in the file. Modify the variables to suit your configuration:
 * 1) ! /bin/sh


 * 1) BEGIN INIT INFO
 * 2) Provides:          kodi
 * 3) Required-Start:    $all
 * 4) Required-Stop:     $all
 * 5) Default-Start:     2 3 4 5
 * 6) Default-Stop:      0 1 6
 * 7) Short-Description: starts instance of Kodi
 * 8) Description:       starts instance of Kodi using start-stop-daemon and xinit
 * 9) END INIT INFO


 * 1) EDIT ME ##################

DAEMON=/usr/bin/xinit
 * 1) path to xinit exec

DAEMON_OPTS=" /usr/local/bin/kodi-standalone -- :0"
 * 1) startup args

NAME=kodi
 * 1) script name

DESC=Kodi
 * 1) app name

RUN_AS=kodi
 * 1) user

PID_FILE=/var/run/kodi.pid
 * 1) Path of the PID file


 * 1) END EDIT ME ##################

test -x $DAEMON || exit 0

set -e

case "$1" in start)        echo "Starting $DESC"        start-stop-daemon --start -c $RUN_AS --background --pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS        ;;  stop) echo "Stopping $DESC" start-stop-daemon --stop --pidfile $PID_FILE ;;

restart|force-reload)       echo "Restarting $DESC"        start-stop-daemon --stop --pidfile $PID_FILE        sleep 5        start-stop-daemon --start -c $RUN_AS --background --pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS        ;;  *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac

exit 0 ........ and choose "Anyone".
 * Test the script by trying to start / stop Kodi with it.
 * 1) /etc/init.d/kodi start
 * 1) /etc/init.d/kodi stop
 * If all is ok, you can add the script to your configuration, by issuing a "update-rc.d"
 * 1) update-rc.d kodi defaults
 * If Kodi does not start, you may need to allow X to start from non-consoles. Under Debian/Ubuntu, run:
 * 1) dpkg-reconfigure x11-common
 * You can now reboot the server, Kodi should be started just after the boot sequence.