#!/bin/sh
IS_MP=$(grep "^MP" /_config/.board)
if [ "$IS_MP" = "" ] ; then
   BOARD=$(cat /_config/.board)
   if [ "$BOARD" != "ACTIVY" ] ; then
      echo "No MediaPortal or Activy"
      exit
   fi

fi

if [ "$1" != "DVB" ] && [ "$1" != "TVOUT" ] ; then
   echo "Illegal Parameter <$1> - must be DVB or TVOUT"
   exit
fi


if [ "$IS_MP" != "" ] ; then
   STATUS=$(grep "DVB" /_config/status/mpscart)
   if [ "$STATUS" != "DVB" ] ; then
      STATUS="FS450"
   fi 

   if [ "$1" != "$STATUS" ] ; then
      echo "Switching to $1"
      mp-switch-video
   fi

   if [ "$(lsmod | grep "^fs450")" = "" ] ; then
      cd /_config/tvout
      sh install.sh
      ./set800X600.sh
   fi

   echo "$1" > /_config/status/mpscart
else
   if [ "$1" = "DVB" ] ; then
      tdk5002cctl -s 1
   else
      tdk5002cctl -s 0
   fi
fi

