Recipe for Kodi and Plex on Nettop

  • base netinst install of jessie, nuc1, or nuc2 - deselect everything from tasksel
    • hostname minix – domain williams.lcl
    • default partition layout (discard, noatime on root)
  • > /etc/motd
  • apt-get --no-install-recommends install aptitude
  • aptitude install ssh (this will pull in xauth, but that's okay)
  • aptitude install fbset screen rsync psmisc file patch ethtool strace tcpdump vim
  • aptitude --without-recommends install dnsutils
  • adduser tdobes adm
  • aptitude install dbus
  • sed -i -e 's/^deb.* main$/& contrib non-free/g' /etc/apt/sources.list
  • aptitude update && aptitude forget-new
  • aptitude install intel-microcode
  • aptitude install ifplugd
  • sed -i -e 's/^INTERFACES=""/INTERFACES="eth0"/g' /etc/default/ifplugd
  • sed -i -e 's/^allow-hotplug eth0/#allow-hotplug eth0/g' /etc/network/interfaces
  • aptitude --without-recommends install ntp
    echo '[Unit]' > /etc/systemd/system/ntp.service
    echo 'Description=Network Time Protocol daemon' >> /etc/systemd/system/ntp.service
    echo 'After=network.target' >> /etc/systemd/system/ntp.service
    echo >> /etc/systemd/system/ntp.service
    echo '[Service]' >> /etc/systemd/system/ntp.service
    echo 'ExecStart=/usr/sbin/ntpd -n -g -u ntp:ntp' >> /etc/systemd/system/ntp.service
    echo >> /etc/systemd/system/ntp.service
    echo '[Install]' >> /etc/systemd/system/ntp.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ntp.service
    systemctl enable ntp.service
  • mkdir -p /etc/systemd/system/ssh.socket.d
    echo '[Socket]' > /etc/systemd/system/ssh.socket.d/port-2222.conf
    echo 'ListenStream=2222' >> /etc/systemd/system/ssh.socket.d/port-2222.conf
    systemctl disable ssh.service && systemctl enable ssh.socket
  • mkdir -p /etc/systemd/system/getty\@tty1.service.d
    echo '[Service]' > /etc/systemd/system/getty\@tty1.service.d/noclear.conf
    echo 'TTYVTDisallocate=no' >> /etc/systemd/system/getty\@tty1.service.d/noclear.conf
  • systemctl mask networking.service # we use ifplugd instead
    echo 'D /run/network 0755 root root' > /etc/tmpfiles.d/debian-networking.conf
    echo 'F /run/network/ifstate 0644 root root - lo=lo' >> /etc/tmpfiles.d/debian-networking.conf
  • aptitude purge acpid acpi-support-base # systemd-logind takes care of this
  • aptitude install wpasupplicant ifmetric iw wireless-tools
  • TODO for future: configure wifi as backup for wired Ethernet
  • systemctl mask keyboard-setup.service
    systemctl mask console-setup.service
    systemctl mask rc-local.service
  • aptitude --without-recommends install irqbalance
  • aptitude install xserver-xorg-video-intel xserver-xorg-input-evdev
  • aptitude install xinit evilwm xdotool x11vnc unclutter x11-xserver-utils
  • sed -i 's/START_UNCLUTTER="true"/START_UNCLUTTER="false"/g' /etc/default/unclutter
    sed -i -e 's/^use-ssh-agent$/#use-ssh-agent/g' /etc/X11/Xsession.options
  • dpkg-reconfigure x11-common – set “Users allowed to start the X server” to “Anybody”
  • aptitude install alsa-utils fonts-freefont-ttf
  • adduser williams
  • adduser williams audio
  • adduser williams video
  • adduser tdobes audio
  • adduser tdobes video
  • echo 'deb http://www.deb-multimedia.org jessie main non-free' > /etc/apt/sources.list.d/dmo.list
    echo 'deb http://www.deb-multimedia.org jessie-backports main' >> /etc/apt/sources.list.d/dmo.list
    aptitude update
    aptitude -o Aptitude::Cmdline::ignore-trust-violations=true install deb-multimedia-keyring
    aptitude update
    aptitude install kodi kodi-pvr-mythtv-cmyth
    aptitude install kodi-visualization-fishbmc kodi-visualization-spectrum
  • echo '#!/bin/sh' > /usr/local/bin/williams-xsession.sh
    echo >> /usr/local/bin/williams-xsession.sh
    echo 'pkill -9 evilwm' >> /usr/local/bin/williams-xsession.sh
    echo 'pkill -9 x11vnc' >> /usr/local/bin/williams-xsession.sh
    echo >> /usr/local/bin/williams-xsession.sh
    echo 'x11vnc -q -usepw -N -ncache 0 -shared -forever &' >> /usr/local/bin/williams-xsession.sh
    echo >> /usr/local/bin/williams-xsession.sh
    echo 'xset s off #disable screensaver' >> /usr/local/bin/williams-xsession.sh
    echo 'xset dpms 0 0 0 #disable automatic power saving' >> /usr/local/bin/williams-xsession.sh
    echo 'unclutter -grab -idle 2 & #daemon to auto-hide mouse' >> /usr/local/bin/williams-xsession.sh
    echo >> /usr/local/bin/williams-xsession.sh
    echo '#SHELL=/bin/bash xterm &' >> /usr/local/bin/williams-xsession.sh
    echo >> /usr/local/bin/williams-xsession.sh
    echo "exec evilwm -fn '*-clean-*'" >> /usr/local/bin/williams-xsession.sh
    chmod +x /usr/local/bin/williams-xsession.sh
    ln -s /usr/local/bin/williams-xsession.sh /home/williams/.xsession
    
    echo '[Unit]' > /etc/systemd/system/startx\@.service
    echo 'Description=Start Xorg for %I' >> /etc/systemd/system/startx\@.service
    echo >> /etc/systemd/system/startx\@.service
    echo '[Service]' >> /etc/systemd/system/startx\@.service
    echo 'ExecStart=-/usr/bin/startx' >> /etc/systemd/system/startx\@.service
    echo 'ExecStopPost=-/usr/bin/pkill -9 -U %I evilwm' >> /etc/systemd/system/startx\@.service
    echo 'User=%I' >> /etc/systemd/system/startx\@.service
    echo 'Restart=always' >> /etc/systemd/system/startx\@.service
    echo 'RestartSec=1' >> /etc/systemd/system/startx\@.service
    echo >> /etc/systemd/system/startx\@.service
    echo '[Install]' >> /etc/systemd/system/startx\@.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/startx\@.service
    # systemctl enable startx\@williams.service # doesn't work on old systemd releases
    ln -s /etc/systemd/system/startx\@.service /etc/systemd/system/multi-user.target.wants/startx\@williams.service
    
    echo '#!/bin/sh' > /usr/local/bin/kodi.sh
    echo >> /usr/local/bin/kodi.sh
    echo 'echo -n waiting for network/server' >> /usr/local/bin/kodi.sh
    echo 'while ! ping -c 1 dvr.williams.lcl > /dev/null 2> /dev/null ; do' >> /usr/local/bin/kodi.sh
    echo '  echo -n .' >> /usr/local/bin/kodi.sh
    echo '  sleep 1' >> /usr/local/bin/kodi.sh
    echo 'done' >> /usr/local/bin/kodi.sh
    echo 'echo done!' >> /usr/local/bin/kodi.sh
    echo >> /usr/local/bin/kodi.sh
    echo '# start kodi' >> /usr/local/bin/kodi.sh
    echo 'exec /usr/bin/kodi --standalone' >> /usr/local/bin/kodi.sh
    chmod +x /usr/local/bin/kodi.sh
    
    echo '[Unit]' > /etc/systemd/system/kodi.service
    echo 'Description=Kodi' >> /etc/systemd/system/kodi.service
    echo 'After=startx@williams.service' >> /etc/systemd/system/kodi.service
    echo 'Requires=startx@williams.service' >> /etc/systemd/system/kodi.service
    echo >> /etc/systemd/system/kodi.service
    echo '[Service]' >> /etc/systemd/system/kodi.service
    echo 'ExecStart=-/usr/local/bin/kodi.sh' >> /etc/systemd/system/kodi.service
    echo 'User=williams' >> /etc/systemd/system/kodi.service
    echo 'Environment=DISPLAY=:0' >> /etc/systemd/system/kodi.service
    echo 'Restart=always' >> /etc/systemd/system/kodi.service
    echo 'RestartSec=1' >> /etc/systemd/system/kodi.service
    echo 'SendSIGHUP=yes' >> /etc/systemd/system/kodi.service
    echo >> /etc/systemd/system/kodi.service
    echo '[Install]' >> /etc/systemd/system/kodi.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/kodi.service
    systemctl enable kodi.service
    
    echo '[Unit]' > /etc/systemd/system/xterm.service
    echo 'Description=xterm for troubleshooting' >> /etc/systemd/system/xterm.service
    echo 'After=startx@williams.service' >> /etc/systemd/system/xterm.service
    echo 'Requires=startx@williams.service' >> /etc/systemd/system/xterm.service
    echo >> /etc/systemd/system/xterm.service
    echo '[Service]' >> /etc/systemd/system/xterm.service
    echo 'ExecStart=-/usr/bin/xterm' >> /etc/systemd/system/xterm.service
    echo 'User=williams' >> /etc/systemd/system/xterm.service
    echo 'Environment=DISPLAY=:0' >> /etc/systemd/system/xterm.service
  • echo 'deb http://www.preining.info/debian jessie pht' > /etc/apt/sources.list.d/plexhometheater.list
    echo 'deb-src http://www.preining.info/debian jessie pht' >> /etc/apt/sources.list.d/plexhometheater.list
    gpg --keyserver pgp.mit.edu --recv-keys 0x860CDC13 && gpg --armor --export 0x860CDC13 | apt-key add -
    aptitude update && aptitude install plexhometheater
    
    echo '#!/bin/sh' > /usr/local/bin/plexhometheater.sh
    echo >> /usr/local/bin/plexhometheater.sh
    echo 'echo -n waiting for network/server' >> /usr/local/bin/plexhometheater.sh
    echo 'while ! ping -c 1 plex.williams.lcl > /dev/null 2> /dev/null ; do' >> /usr/local/bin/plexhometheater.sh
    echo '  echo -n .' >> /usr/local/bin/plexhometheater.sh
    echo '  sleep 1' >> /usr/local/bin/plexhometheater.sh
    echo 'done' >> /usr/local/bin/plexhometheater.sh
    echo 'echo done!' >> /usr/local/bin/plexhometheater.sh
    echo >> /usr/local/bin/plexhometheater.sh
    echo '# start plex' >> /usr/local/bin/plexhometheater.sh
    echo 'exec /usr/bin/plexhometheater' >> /usr/local/bin/plexhometheater.sh
    chmod +x /usr/local/bin/plexhometheater.sh
    
    echo '[Unit]' > /etc/systemd/system/plexhometheater.service
    echo 'Description=Plex Home Theater' >> /etc/systemd/system/plexhometheater.service
    echo 'After=startx@williams.service' >> /etc/systemd/system/plexhometheater.service
    echo 'Requires=startx@williams.service' >> /etc/systemd/system/plexhometheater.service
    echo >> /etc/systemd/system/plexhometheater.service
    echo '[Service]' >> /etc/systemd/system/plexhometheater.service
    echo 'ExecStart=-/usr/local/bin/plexhometheater.sh' >> /etc/systemd/system/plexhometheater.service
    echo 'User=williams' >> /etc/systemd/system/plexhometheater.service
    echo 'Environment=DISPLAY=:0' >> /etc/systemd/system/plexhometheater.service
    echo 'Restart=always' >> /etc/systemd/system/plexhometheater.service
    echo 'RestartSec=1' >> /etc/systemd/system/plexhometheater.service
    echo >> /etc/systemd/system/plexhometheater.service
    echo '[Install]' >> /etc/systemd/system/plexhometheater.service
    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/plexhometheater.service
    systemctl enable plexhometheater.service
  • run alsamixer and configure audio as needed
  • mkdir ~williams/.vnc
    x11vnc -storepasswd **PASSWORD** ~williams/.vnc/passwd
    chown -R williams:williams ~williams/.vnc
    chmod 0600 ~williams/.vnc/passwd
  • Network shared Kodi database and settings:
    aptitude install nfs-common
    echo 'memoryalpha:/tank/videos        /mnt/videos     nfs     _netdev,auto,hard,nfsvers=3     0       0' >> /etc/fstab
    mkdir -p /mnt/videos
    mount /mnt/videos
    
    mv ~williams/.kodi ~williams/old-dot-kodi
    ln -s /mnt/videos/dot-kodi ~williams/.kodi
  • Allow power off from Kodi:
    echo '[Actions for williams user]' > /etc/polkit-1/localauthority/50-local.d/kodi-williams.pkla
    echo 'Identity=unix-user:williams' >> /etc/polkit-1/localauthority/50-local.d/kodi-williams.pkla
    echo 'Action=org.freedesktop.login1.reboot;org.freedesktop.login1.power-off' >> /etc/polkit-1/localauthority/50-local.d/kodi-williams.pkla
    echo 'ResultAny=yes' >> /etc/polkit-1/localauthority/50-local.d/kodi-williams.pkla
    echo 'ResultInactive=yes' >> /etc/polkit-1/localauthority/50-local.d/kodi-williams.pkla
    echo 'ResultActive=yes' >> /etc/polkit-1/localauthority/50-local.d/kodi-williams.pkla
  • systemctl start startx@williams && systemctl start kodi, then configure Kodi as needed

See also: https://www.preining.info/blog/2014/12/plex-home-theater-1-3-2-debian-build/ See also: https://forums.plex.tv/index.php/topic/87255-the-plex-home-theater-debs-thread/?p=505692

computer/kodi_nettop.txt · Last modified: 2016/05/24 22:15 by tdobes
Recent changes RSS feed Driven by DokuWiki Valid XHTML 1.0 Valid CSS