#!/bin/sh
#
# run vdr-sxfe
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
test -e /var/run/xbmc.pid && test -e /proc/$(cat /var/run/xbmc.pid) && { echo "$0 is already running"; exit; }
echo $$ > /var/run/xbmc.pid
python /usr/share/xbmc/FEH.py || exit
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 /var/run/xbmc.pid /tmp/xbmc_stop