mirror of
https://github.com/LibreELEC/LibreELEC.tv
synced 2025-09-24 19:46:01 +07:00
95 lines
3.2 KiB
Bash
Executable File
95 lines
3.2 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.tvheadend
|
|
|
|
ADDON_SETTINGS="$ADDON_HOME/settings.xml"
|
|
XMLTV_FILE="$ADDON_DIR/bin/tv_grab_file"
|
|
XMLTV_SETTINGS_DIR="$ADDON_HOME/xmltv"
|
|
XMLTV_SETTINGS_FILE="$XMLTV_SETTINGS_DIR/config"
|
|
DVR_SETTINGS_DIR="$ADDON_HOME/dvr"
|
|
DVR_SETTINGS_FILE="$DVR_SETTINGS_DIR/config"
|
|
DVR_DIR="$HOME/recordings"
|
|
TIMESHIFT_SETTINGS_DIR="$ADDON_HOME/timeshift"
|
|
TIMESHIFT_SETTINGS_FILE="$TIMESHIFT_SETTINGS_DIR/config"
|
|
TIMESHIFT_DIR="$ADDON_HOME/cache/timeshift"
|
|
|
|
chmod a+x $ADDON_DIR/bin/*
|
|
|
|
if [ ! -f "$XMLTV_SETTINGS_FILE" ]; then
|
|
mkdir -p $XMLTV_SETTINGS_DIR
|
|
if [ -f $ADDON_DIR/xmltv-config ]; then
|
|
cp $ADDON_DIR/xmltv-config $XMLTV_SETTINGS_FILE
|
|
fi
|
|
fi
|
|
|
|
if [ ! -f "$DVR_SETTINGS_FILE" ]; then
|
|
mkdir -p $DVR_DIR
|
|
mkdir -p $DVR_SETTINGS_DIR
|
|
if [ -f $ADDON_DIR/dvr-config ]; then
|
|
cp $ADDON_DIR/dvr-config $DVR_SETTINGS_FILE
|
|
fi
|
|
fi
|
|
|
|
if [ ! -f "$TIMESHIFT_SETTINGS_FILE" ]; then
|
|
mkdir -p $TIMESHIFT_DIR
|
|
mkdir -p $TIMESHIFT_SETTINGS_DIR
|
|
if [ -f $ADDON_DIR/timeshift-config ]; then
|
|
cp $ADDON_DIR/timeshift-config $TIMESHIFT_SETTINGS_FILE
|
|
fi
|
|
fi
|
|
|
|
if [ "$DEBUG" = "yes" ]; then
|
|
TVHEADEND_ARG="-C -s -u root -g video -c $ADDON_HOME"
|
|
else
|
|
TVHEADEND_ARG="-C -u root -g video -c $ADDON_HOME"
|
|
fi
|
|
|
|
# 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 Tvheadend "### 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))/frontend* ] ; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
fi
|
|
|
|
if [ "$PRELOAD_CAPMT_CA" == "true" ] ; then
|
|
logger -t Tvheadend "### Preloading capmt_ca.so library ###"
|
|
LD_PRELOAD="$ADDON_DIR/bin/capmt_ca.so $LD_PRELOAD" exec tvheadend $TVHEADEND_ARG &>$ADDON_LOG_FILE
|
|
else
|
|
exec tvheadend $TVHEADEND_ARG &>$ADDON_LOG_FILE
|
|
fi
|