#!/bin/bash

INST_PATH=/usr/share/selecthw
CONFDIR=/var/cache/selecthw
REPODIR=/var/www/repos/apt

. ${INST_PATH}/utils
. /etc/default/weston

###############################################################

DISTRO="$(lsb_release -sc)"
oldconfig=${CONFDIR}/board
OLDCPU=""

findCPU

if [ -f $oldconfig ]; then
    OLDCPU=$(cat $oldconfig)
fi

if [ -d ${REPODIR} ]; then
    if [ "x$CPU" != "x" ] ; then
        if [ "x$CPU" != "x$OLDCPU" ] ; then
            rm -f $oldconfig
            exit 0
        fi
    fi
fi

/bin/chvt 7
sleep 0.5
/usr/bin/weston-launch ${LAUNCH_ARGS} -- --log=${LOG_FILE}
exit 0
