diff --git a/packages/mediacenter/xbmc-pvr/init.d/93_xbmc b/packages/mediacenter/xbmc-pvr/init.d/93_xbmc index 655c4f04fd..4477d39a2f 100644 --- a/packages/mediacenter/xbmc-pvr/init.d/93_xbmc +++ b/packages/mediacenter/xbmc-pvr/init.d/93_xbmc @@ -71,22 +71,40 @@ fi cpupower frequency-set -g ondemand > /dev/null 2>&1 )& +# prevent restrating XBMC at reboot or shutdown + LOCKDIR="/var/lock/" + LOCKFILE="xbmc.disabled" + [ -f "$LOCKDIR/$LOCKFILE" ] && rm -f "$LOCKDIR/$LOCKFILE" & + # starting XBMC usleep $XBMC_STARTDELAY while true; do + while [ -f "$LOCKDIR/$LOCKFILE" ]; do + usleep 250000 + done + DISPLAY=:0.0 /usr/lib/xbmc/xbmc.bin $XBMC_ARGS > /dev/null 2>&1 RET=$? case "$RET" in 0) - poweroff -f + if [ ! $(pidof console-kit-daemon) ]; then + touch "$LOCKDIR/$LOCKFILE" + poweroff -f + fi ;; 64) - poweroff -f + if [ ! $(pidof console-kit-daemon) ]; then + touch "$LOCKDIR/$LOCKFILE" + poweroff -f + fi ;; 66) - reboot + if [ ! $(pidof console-kit-daemon) ]; then + touch "$LOCKDIR/$LOCKFILE" + reboot + fi ;; 255) echo "Abnormal Exit. Exited with code $RET" diff --git a/packages/mediacenter/xbmc-pvr/install b/packages/mediacenter/xbmc-pvr/install index 731dc18ce2..572f934e6c 100755 --- a/packages/mediacenter/xbmc-pvr/install +++ b/packages/mediacenter/xbmc-pvr/install @@ -27,6 +27,7 @@ PYTHON_LIBDIR="`ls -d $INSTALL/usr/lib/python*`" mkdir -p $INSTALL/usr/bin cp $PKG_DIR/scripts/cputemp $INSTALL/usr/bin cp $PKG_DIR/scripts/gputemp $INSTALL/usr/bin + cp $PKG_DIR/scripts/wait_on_xbmc_exit $INSTALL/usr/bin cp $PKG_BUILD/tools/EventClients/Clients/XBMC\ Send/xbmc-send.py $INSTALL/usr/bin/xbmc-send mkdir -p $INSTALL/usr/lib/xbmc diff --git a/packages/mediacenter/xbmc-pvr/scripts/wait_on_xbmc_exit b/packages/mediacenter/xbmc-pvr/scripts/wait_on_xbmc_exit new file mode 100755 index 0000000000..f786a63123 --- /dev/null +++ b/packages/mediacenter/xbmc-pvr/scripts/wait_on_xbmc_exit @@ -0,0 +1,29 @@ +#!/bin/sh + +################################################################################ +# Copyright (C) 2009-2010 OpenELEC.tv +# http://www.openelec.tv +# +# This Program 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, or (at your option) +# any later version. +# +# This Program 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.tv; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# http://www.gnu.org/copyleft/gpl.html +################################################################################ + +count=0 + +while [ $(pidof xbmc.bin) -a $count -le 20 ]; do + usleep 250000 + logger -t wait_on_xbmc_exit "### Waiting for XBMC to Exit - $count ###" + count=$((count+1)) +done diff --git a/packages/mediacenter/xbmc/init.d/93_xbmc b/packages/mediacenter/xbmc/init.d/93_xbmc index b8af6b2b3a..97d6723376 100644 --- a/packages/mediacenter/xbmc/init.d/93_xbmc +++ b/packages/mediacenter/xbmc/init.d/93_xbmc @@ -71,22 +71,40 @@ fi cpupower frequency-set -g ondemand > /dev/null 2>&1 )& +# prevent restrating XBMC at reboot or shutdown + LOCKDIR="/var/lock/" + LOCKFILE="xbmc.disabled" + [ -f "$LOCKDIR/$LOCKFILE" ] && rm -f "$LOCKDIR/$LOCKFILE" & + # starting XBMC usleep $XBMC_STARTDELAY while true; do + while [ -f "$LOCKDIR/$LOCKFILE" ]; do + usleep 250000 + done + DISPLAY=:0.0 /usr/lib/xbmc/xbmc.bin $XBMC_ARGS > /dev/null 2>&1 RET=$? case "$RET" in 0) - poweroff -f + if [ ! $(pidof console-kit-daemon) ]; then + touch "$LOCKDIR/$LOCKFILE" + poweroff -f + fi ;; 64) - poweroff -f + if [ ! $(pidof console-kit-daemon) ]; then + touch "$LOCKDIR/$LOCKFILE" + poweroff -f + fi ;; 66) - reboot + if [ ! $(pidof console-kit-daemon) ]; then + touch "$LOCKDIR/$LOCKFILE" + reboot + fi ;; 255) echo "Abnormal Exit. Exited with code $RET" diff --git a/packages/mediacenter/xbmc/install b/packages/mediacenter/xbmc/install index 731dc18ce2..572f934e6c 100755 --- a/packages/mediacenter/xbmc/install +++ b/packages/mediacenter/xbmc/install @@ -27,6 +27,7 @@ PYTHON_LIBDIR="`ls -d $INSTALL/usr/lib/python*`" mkdir -p $INSTALL/usr/bin cp $PKG_DIR/scripts/cputemp $INSTALL/usr/bin cp $PKG_DIR/scripts/gputemp $INSTALL/usr/bin + cp $PKG_DIR/scripts/wait_on_xbmc_exit $INSTALL/usr/bin cp $PKG_BUILD/tools/EventClients/Clients/XBMC\ Send/xbmc-send.py $INSTALL/usr/bin/xbmc-send mkdir -p $INSTALL/usr/lib/xbmc diff --git a/packages/mediacenter/xbmc/scripts/wait_on_xbmc_exit b/packages/mediacenter/xbmc/scripts/wait_on_xbmc_exit new file mode 100755 index 0000000000..f786a63123 --- /dev/null +++ b/packages/mediacenter/xbmc/scripts/wait_on_xbmc_exit @@ -0,0 +1,29 @@ +#!/bin/sh + +################################################################################ +# Copyright (C) 2009-2010 OpenELEC.tv +# http://www.openelec.tv +# +# This Program 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, or (at your option) +# any later version. +# +# This Program 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.tv; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# http://www.gnu.org/copyleft/gpl.html +################################################################################ + +count=0 + +while [ $(pidof xbmc.bin) -a $count -le 20 ]; do + usleep 250000 + logger -t wait_on_xbmc_exit "### Waiting for XBMC to Exit - $count ###" + count=$((count+1)) +done diff --git a/packages/sysutils/ConsoleKit/scripts/ck-system-restart b/packages/sysutils/ConsoleKit/scripts/ck-system-restart index 003c352270..35aa9e976b 100755 --- a/packages/sysutils/ConsoleKit/scripts/ck-system-restart +++ b/packages/sysutils/ConsoleKit/scripts/ck-system-restart @@ -20,4 +20,8 @@ # http://www.gnu.org/copyleft/gpl.html ################################################################################ +LOCKDIR="/var/lock/" +LOCKFILE="xbmc.disabled" +touch "$LOCKDIR/$LOCKFILE" +wait_on_xbmc_exit reboot diff --git a/packages/sysutils/ConsoleKit/scripts/ck-system-stop b/packages/sysutils/ConsoleKit/scripts/ck-system-stop index a6e24e8385..edaa2b308c 100755 --- a/packages/sysutils/ConsoleKit/scripts/ck-system-stop +++ b/packages/sysutils/ConsoleKit/scripts/ck-system-stop @@ -20,4 +20,8 @@ # http://www.gnu.org/copyleft/gpl.html ################################################################################ +LOCKDIR="/var/lock/" +LOCKFILE="xbmc.disabled" +touch "$LOCKDIR/$LOCKFILE" +wait_on_xbmc_exit poweroff