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

VDR_CONF="/etc/conf.d/vdr"

ALL_VARS=$(grep "^/etc" $ADMIN_CFG_FILE | cut -f 2 -d ":" | grep -v "^PLG_")

for i in $ALL_VARS ; do
   VAL=$($GETVAL ${i})
   VE=$(grep -m 1 "^$i=" $VDR_CONF | cut -f 2 -d '"')
#   logger -s "ADMIN - ${i}: ${VAL}-${VE} "
   if [ "$VE" = "" ] ; then
      logger -s "Adding ${i}=\"${VAL}\" to $VDR_CONF"
      echo "${i}=\"${VAL}\"" >> $VDR_CONF
   else   
      if [ "$VE" != "$VAL" ] ; then
         logger -s "Changing ${i} ($VE) to \"${VAL}\" in $VDR_CONF"
         sed -i $VDR_CONF -e "s/^${i}=.*/${i}=\"${VAL}\"/"
      fi   
   fi
done
echo 'Done!'
exit 0

