#!/bin/sh
#
# run vdr-sxfe
. /etc/rc.config
rm -f /tmp/xbmc_stop
case "$1" in
-k)
touch /tmp/xbmc_stop
killproc "/usr/bin/xbmc.bin" 10
exit $?
;;
-r)
killproc "/usr/bin/xbmc.bin" 10
exit $?
;;
-n)
norestart=1
;;
-*)
echo "Usage $0 {-k | -r | -q}"
echo " -k kill xbmc"
echo " -r restart xbmc"
echo " -n no restart if an error occur"
exit 1
;;
esac
# accept only one instance
ps=$(ps); echo "$ps" | grep "{${0##*/}}" | grep -q -v $$ && { echo "${0##*/} is already running"; exit 1; }
python /usr/share/xbmc/FEH.py || exit
if [ -e /etc/lircd.conf -a -n "$(grep "LIRC." /etc/vdr/remote.conf 2>/dev/null)" -a ! -e /usr/share/xbmc/userdata/Lircmap.xml ]; then
update_xbmclircmapxml.sh
fi
sed "s|.*|$XBMC_PORT|" -i /root/.xbmc/userdata/guisettings.xml
while (true) do
. /etc/rc.config
if [ -e /etc/vdr/setup.conf -a -e /root/.xbmc/userdata/guisettings.xml ]; then
timeout=$(grep "MinUserInactivity" /etc/vdr/setup.conf | sed "s/.*= //")
sed "s|.*|$timeout|" -i /root/.xbmc/userdata/guisettings.xml
fi
test -e /tmp/xbmc_stop && break
# schnelle wiederholte Neustarts verzögern
if [ 0$starttime -gt $(( `date +%s` - 15 )) ]; then
sleep 10 "#delaying xbmc restart"
fi
starttime=`date +%s`
# starte xbmc
eval /usr/lib/xbmc/xbmc.bin $XBMC_ARGS >>/var/log/xbmc 2>&1
status=$?
echo -n "xbmc exits at "; date
test -e /tmp/xbmc_stop -o "$norestart" = "1" && break
case $status in
0)
break
;;
64)
shutdown
break
;;
66)
reboot
break
;;
esac
done
rm -f /tmp/xbmc_stop