#!/bin/sh

# global configuration file - see vdr-config for more info
CONFIGFILE="/var/lib/vdr/kanotix-vdr/kanotix-vdr.conf"

# Localisation
export TEXTDOMAINDIR="/usr/share/locale"
export TEXTDOMAIN=kanotix-vdr

# override tool behaviour through distro-defaults
FLL_DISTRO_MODE="installed"

[ -r /etc/default/distro ] && source /etc/default/distro

[ "$FLL_DISTRO_MODE" == "live" ] && /usr/sbin/fix-unionfs 2>/dev/null

if [ "$(grep ^LanguageMode $CONFIGFILE | cut -d= -f2)" -ne 1 ]; then
    # Set VDR-language automatically
    # source sysconfig to detect the default system language
    [ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
    lang=$(grep ^OSDLanguage /var/lib/vdr/setup.conf | cut -d= -f2)
    [ "$lang" ] && old=$(echo $lang)
    [ -z "$lang" ] && old=0
    new=0 # default language, if detected language is not German
    [ "$LANGUAGE" = "de" ] && new=1
    if [ "$old" != "$new" ]; then
        if [ -z "$lang" ]; then
            echo "OSDLanguage = $new" >> /var/lib/vdr/setup.conf
        else
            perl -pi -e "s/^OSDLanguage =.*$/OSDLanguage = $new/" /var/lib/vdr/setup.conf
        fi
    fi
fi

/etc/init.d/vdr start
/etc/init.d/vdradmin-am start
echo $"Please wait ..."
sleep 10

