Files
LibreELEC.tv/packages/addons/service/multimedia/vdr-addon/source/bin/vdr.start
2014-06-08 15:37:58 +02:00

168 lines
5.1 KiB
Bash
Executable File

#!/bin/sh
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
#
# OpenELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# OpenELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
. /etc/profile
oe_setup_addon service.multimedia.vdr-addon
fix_config() {
if [ -f "$ADDON_CONFIG_DIR/setup.conf" ]; then
sed -i -e '/^$/d' $ADDON_CONFIG_DIR/setup.conf
sed -i -e '/^AlwaysSortFoldersFirst.*$/d' $ADDON_CONFIG_DIR/setup.conf
sed -i -e '/^SetSystemTime.*$/d' $ADDON_CONFIG_DIR/setup.conf
sed -i -e '/^epgsearch.SVDRPPort.*$/d' $ADDON_CONFIG_DIR/setup.conf
sed -i -e '/^OSD.*$/d' $ADDON_CONFIG_DIR/setup.conf
sed -i -e '/^Font.*$/d' $ADDON_CONFIG_DIR/setup.conf
fi
cat >>$ADDON_CONFIG_DIR/setup.conf << MYDATA
AlwaysSortFoldersFirst = 1
SetSystemTime = 0
epgsearch.SVDRPPort = 6419
OSDSkin = sttng
MYDATA
}
ADDON_CONFIG_DIR="$ADDON_HOME/config"
ADDON_PLUGIN_DIR="$ADDON_DIR/plugin"
chmod a+x $ADDON_DIR/bin/*
ADDON_CACHE_DIR="$ADDON_HOME/cache"
if [ ! -f "$ADDON_CACHE_DIR" ]; then
mkdir -p $ADDON_CACHE_DIR
fi
VDR_ARG="-g /tmp --no-kbd"
if [ "$DEBUG" = "yes" ]; then
VDR_ARG="$VDR_ARG --log=3"
else
VDR_ARG="$VDR_ARG --log=1"
fi
SVDRP_PORT=0
# epgsearch needs svdrp
if [ "$ENABLE_EPGSEARCH" == "true" ] ; then
SVDRP_PORT=6419
fi
VDR_ARG="$VDR_ARG --port=$SVDRP_PORT"
VDR_ARG="$VDR_ARG --config=$ADDON_CONFIG_DIR"
VDR_ARG="$VDR_ARG --resdir=$ADDON_DIR/res"
VDR_ARG="$VDR_ARG --cachedir=$ADDON_CACHE_DIR"
VDR_ARG="$VDR_ARG --lib=$ADDON_PLUGIN_DIR"
VDR_ARG="$VDR_ARG --video=\"$VDR_VIDEO_DIR\""
if [ "$ENABLE_EXTERNAL_RECCMD" == "true" ] ; then
if [ ! -z "$EXTERNAL_RECCMD_PATH" -a -x "$EXTERNAL_RECCMD_PATH" ] ; then
VDR_ARG="$VDR_ARG -r \"$EXTERNAL_RECCMD_PATH\""
fi
fi
# keep softcam first
if [ "$ENABLE_SOFTCAM" == "true" ] ; then
VDR_ARG="$VDR_ARG -P dvbapi"
fi
VDR_ARG="$VDR_ARG -P wirbelscan -P wirbelscancontrol"
if [ "$ENABLE_IPTV" == "true" ] ; then
VDR_ARG="$VDR_ARG -P iptv"
fi
if [ "$ENABLE_STREAMDEV_SERVER" == "true" ] ; then
VDR_ARG="$VDR_ARG -P streamdev-server"
fi
if [ "$ENABLE_STREAMDEV_CLIENT" == "true" ] ; then
VDR_ARG="$VDR_ARG -P streamdev-client"
fi
if [ "$ENABLE_LIVE" == "true" ] ; then
VDR_ARG="$VDR_ARG -P 'live -i $LIVE_IP -p $LIVE_PORT'"
fi
if [ "$ENABLE_CONTROL" == "true" ] ; then
VDR_ARG="$VDR_ARG -P 'control -p $CONTROL_PORT'"
fi
if [ "$ENABLE_EEPG" == "true" ] ; then
VDR_ARG="$VDR_ARG -P eepg"
fi
if [ "$ENABLE_EPGSEARCH" == "true" ] ; then
VDR_ARG="$VDR_ARG -P epgsearch"
fi
if [ "$ENABLE_DUMMYDEVICE" == "true" ] ; then
VDR_ARG="$VDR_ARG -P dummydevice"
fi
if [ "$ENABLE_SATIP" == "true" ] ; then
VDR_ARG="$VDR_ARG -P satip"
fi
if [ "$ENABLE_XMLTV2VDR" == "true" ] ; then
VDR_ARG="$VDR_ARG -P 'xmltv2vdr --epgfile=$ADDON_CACHE_DIR/epg.db'"
# xmltv2vdr needs /var/run/vdr
grep -q " /var/run/vdr " /proc/mounts || ( mkdir -p /var/run/vdr && mount -t tmpfs -o size=10% tmpfs /var/run/vdr )
#handle epgsources
mkdir -p /var/lib/epgsources
mkdir -p $ADDON_HOME/config/epgsources
for source in `find $ADDON_DIR/config/epgsources -type f`; do
if [ ! -e $ADDON_HOME/config/epgsources/`basename $source` ] ; then
cp $source $ADDON_HOME/config/epgsources/
fi
done
for source in `find $ADDON_HOME/config/epgsources -type f`; do
cp $source /var/lib/epgsources
done
fi
# vnsi/xvdr last
VDR_ARG="$VDR_ARG -P $PVR_PLUGIN"
cd $ADDON_DIR/config
mkdir -p $ADDON_CONFIG_DIR
mkdir -p "$VDR_VIDEO_DIR"
for dir in `find . -type d`; do
mkdir -p $ADDON_CONFIG_DIR/$dir
done
for config in `find . -type f`; do
if [ ! -f $ADDON_CONFIG_DIR/$config ]; then
cp $config $ADDON_CONFIG_DIR/$config
fi
done
# start userspace DVB driver/addon
for driver_dvb in $(find /storage/.xbmc/addons/driver.dvb.*/bin/userspace-driver.sh -type f 2>/dev/null); do
driver_dvb_name=$(echo $driver_dvb | awk 'BEGIN {FS="/"} {printf("%s", $5)}')
logger -t VDR "### Loading userspace DVB driver: $driver_dvb_name ###"
# use ". " because of variable export
. $driver_dvb
done
# (wait for) at least 1 adapter (xbmc allows to set 0)
# xbmc allows "numeric" type field to be empty. lets handle thaat
[ "$NUM_ADAPTERS" = "" ] && NUM_ADAPTERS=1
# 0 does not make sense. should be 1 or more
[ $NUM_ADAPTERS -lt 1 ] && NUM_ADAPTERS=1
if [ "$WAIT_FOR_FEINIT" == "true" ] ; then
while [ true ] ; do
if [ -e /dev/dvb/adapter$((NUM_ADAPTERS-1))/frontend0 ] ; then
break
fi
sleep 1
done
fi
fix_config
eval LANG=en_US.UTF-8 exec vdr.bin $VDR_ARG