Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 73 lines (65 sloc) 1.62 KB
#!/bin/bash
BOXEE_HOME=/opt/boxee
BOXEE_PROC=Boxee
BOXEE_HOME=${XBMC_HOME=${BOXEE_HOME}}
export XBMC_HOME=${BOXEE_HOME}
export BOXEE_HOME
BOXEE_PID=/tmp/run-boxee.pid
CURRENT_PATH=`pwd`
ALREADY_RUN=0
LC_ALL="en.gb"
if [ -f ${BOXEE_PID} ] ; then
CURRENT_PID=`cat ${BOXEE_PID}`
COMPARE_PID=`ps -ef | grep run-boxee | grep -v grep | awk '{print $2}' | xargs`
for pid in ${COMPARE_PID}
do
if [ ${CURRENT_PID} -eq ${pid} ]; then
ALREADY_RUN=1
BLOCKING_PROC='run-boxee'
fi
done
fi
if [ ${ALREADY_RUN} -ne 1 ] && ps -ef | grep "./Boxee" | grep -v grep > /dev/null ; then
ALREADY_RUN=1
BLOCKING_PROC='boxee'
fi
if [ ${ALREADY_RUN} -ne 0 ]; then
echo "BOXEE is already running... (${BLOCKING_PROC})"
exit
#else
# echo $$ >${BOXEE_PID}
# ${BOXEE_HOME}/${BOXEE_PROC} --standalone
fi
if which pulse-session; then
BOXEE="pulse-session ${BOXEE_HOME}/${BOXEE_PROC} --standalone \"$@\""
else
BOXEE="${BOXEE_HOME}/${BOXEE_PROC} --standalone \"$@\""
fi
LOOP=1
CRASHCOUNT=0
LASTSUCCESSFULSTART=$(date +%s)
ulimit -c unlimited
while (( $LOOP ))
do
$BOXEE
RET=$?
NOW=$(date +%s)
if (( ($RET >= 64 && $RET <=66) || $RET == 0 )); then # clean exit
LOOP=0
else # crash
DIFF=$((NOW-LASTSUCCESSFULSTART))
if (($DIFF > 60 )); then # Not on startup, ignore
LASTSUCESSFULSTART=$NOW
CRASHCOUNT=0
else # at startup, look sharp
CRASHCOUNT=$((CRASHCOUNT+1))
if (($CRASHCOUNT >= 3)); then # Too many, bail out
LOOP=0
echo "BOXEE has exited uncleanly 3 times in the ${DIFF}s. Something is probably wrong"
fi
fi
fi
done
pkill -9 Boxee
${BOXEE_HOME}/give_me_my_mouse_back
rm ${BOXEE_PID}
Something went wrong with that request. Please try again.