#!/bin/bash
#
source /etc/conf.d/vdr.admin.cfg

if [ "$1" != "" ] ; then
   LIRC=$1
else
   LIRC=`$GETVAL LIRC`
fi

/etc/init.d/lircd stop
if [ "$LIRC" = "KBD" ] || [ "$LIRC" = "Tastatur" ] ; then
   /etc/init.d/lircd stop
   cp /_config/install/vdr/remote.conf.kbd /etc/vdr/remote.conf  >/dev/null 2>&1
   rc-update del lircd  >/dev/null 2>&1
   rc-update del irexec  >/dev/null 2>&1
   if [ "$1" != "" ] ; then
      $SETVAL LIRC Tastatur
   fi
else
   rc-update add lircd boot >/dev/null 2>&1
   rc-update add irexec default >/dev/null 2>&1
   cp /_config/install/vdr/remote.conf.lirc /etc/vdr/remote.conf  >/dev/null 2>&1
   if [ -f /_config/install/lircd.conf.$LIRC ] ; then
      cp -f /_config/install/lircd.conf.$LIRC /etc/lircd.conf  >/dev/null 2>&1
      if [ "$1" != "" ] ; then
         $SETVAL LIRC $1
      fi
#      mv $2/etc/rc.d/rc3.d/org/*lircd  $2/etc/rc.d/rc3.d/  >/dev/null 2>&1
   else
      if [ "$LIRC" != "Other" ]  ; then
         echo "Unknown parameter $1"
         exit 1
      fi
   fi
   /etc/init.d/irexec start
fi
echo 'Done!'
exit 0

