#!/bin/sh -e

# Including helpers
. /boot/ods-install/helpers.sh

# Updates distibution
log "Updating distibution ..."

# Something previsously broken, revert and restart
# Remove stretch source
if [ -f /etc/apt/sources.list.bak ]; then
	mv -f /etc/apt/sources.list.bak /etc/apt/sources.list
fi
apt-get update
DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none \
apt-get -fuy --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
upgrade -y

# Installs packages
log "Installing packages ..."

DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none \
apt-get -fuy --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
install -y xserver-xorg xinit lxde-core lxterminal lxappearance lightdm unclutter chromium-browser

# Sets up hostname
log "Setting hostname ..."
echo ods-player > /etc/hostname
