aboutsummaryrefslogtreecommitdiff
path: root/tools/Linux
diff options
context:
space:
mode:
authorceros7 <ceros7@svn>2010-08-01 02:49:26 +0000
committerceros7 <ceros7@svn>2010-08-01 02:49:26 +0000
commit160e0c24333a2dbf18f469fef52c3376fc0b329c (patch)
tree14418172d997d40ed3650a7244b12a127f5d510e /tools/Linux
parent98ba5e18b1684f447ce9acda199e76344d1954f4 (diff)
Auto add upstart script for xbmc-live via debhelper.
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@32387 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'tools/Linux')
-rw-r--r--tools/Linux/packaging/debian/xbmc-live.upstart231
1 files changed, 231 insertions, 0 deletions
diff --git a/tools/Linux/packaging/debian/xbmc-live.upstart b/tools/Linux/packaging/debian/xbmc-live.upstart
new file mode 100644
index 0000000000..6d166e8e26
--- /dev/null
+++ b/tools/Linux/packaging/debian/xbmc-live.upstart
@@ -0,0 +1,231 @@
+# xbmc-live
+#
+# init XBMC environment and starts XBMC in fullscreen (if asked to do so)
+
+# Copyright (C) 2005-2008 Team XBMC
+# http://www.xbmc.org
+#
+# 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 XBMC; 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
+
+description "XBMCLive"
+author "Luigi Capriotti"
+
+start on (filesystem and stopped udevtrigger)
+
+stop on runlevel [06]
+
+pre-start script
+ get_opt() {
+ echo "$@" | cut -d "=" -f 2
+ }
+
+ CMDLINE=$(cat /proc/cmdline)
+
+ #Process command line options
+ XBMC_PARAMS=""
+ for i in ${CMDLINE}; do
+ case "${i}" in
+ xbmc\=*)
+ XBMC_PARAMS=$(get_opt $i)
+ ;;
+ esac
+ done
+ echo $XBMC_PARAMS > /tmp/xbmcliveParams
+
+ # Relies on init scripts to mount boot device on a specified directory
+ # TODO hardcode the already mounted directories (speed)
+ # XBMC Live V2
+ BOOTMEDIADIRECTORY="image"
+ BOOTMEDIAMOUNTPOINT="$(mount | grep $BOOTMEDIADIRECTORY | cut -f 3 -d ' ')"
+ if [ ! -n "$BOOTMEDIAMOUNTPOINT" ]; then
+ # XBMC Live V1
+ BOOTMEDIADIRECTORY="bootMedia"
+ BOOTMEDIAMOUNTPOINT="$(mount | grep $BOOTMEDIADIRECTORY | cut -f 3 -d ' ')"
+ fi
+
+ # Executes hooks (if any) in the "Hooks" directory
+ for hook in $(ls -1 $BOOTMEDIAMOUNTPOINT/Hooks/*.sh)
+ do
+ sh $hook
+ done
+
+
+ # Identify Ubuntu release
+ LSBRELEASE="$(lsb_release -r | cut -f2 | sed 's/\.//')"
+
+ # Identify GPU, Intel by default
+ GPUTYPE="INTEL"
+
+ GPU=$(lspci -nn | grep 0300)
+ # 10de == NVIDIA
+ if [ "$(echo $GPU | grep 10de)" ]; then
+ GPUTYPE="NVIDIA"
+ else
+ # 1002 == AMD
+ if [ "$(echo $GPU | grep 1002)" ]; then
+ GPUTYPE="AMD"
+ fi
+ fi
+
+ # Generates valid xorg.conf for proprietary drivers if missing
+ if [ ! -e /etc/X11/xorg.conf ] && ! grep -q -i nogenxconf /tmp/xbmcliveParams ; then
+ if [ "$GPUTYPE" = "NVIDIA" ]; then
+ if [ $LSBRELEASE -gt 910 ]; then
+ # only on lucid!
+ update-alternatives --set gl_conf /usr/lib/nvidia-current/ld.so.conf
+ ldconfig
+ fi
+
+ # run nvidia-xconfig
+ /usr/bin/nvidia-xconfig -s --no-logo --no-composite --no-dynamic-twinview --force-generate
+
+ # Disable scaling to make sure the gpu does not loose performance
+ sed -i -e 's%Section \"Screen\"%&\n Option \"FlatPanelProperties\" \"Scaling = Native\"\n Option \"HWCursor\" \"Off\"%' /etc/X11/xorg.conf
+ fi
+ if [ "$GPUTYPE" = "AMD" ]; then
+ if [ $LSBRELEASE -gt 910 ]; then
+ # only on lucid!
+ update-alternatives --set gl_conf /usr/lib/fglrx/ld.so.conf
+ ldconfig
+ fi
+
+ # run aticonfig
+ /usr/bin/aticonfig --initial --sync-vsync=on -f
+ fi
+ fi
+
+ if [ ! "$(mount | grep iso9660)" ]; then
+ if ! grep -q -i noredir /tmp/xbmcliveParams ; then
+ if [ -n "$BOOTMEDIAMOUNTPOINT" ]; then
+ if [ ! -d $BOOTMEDIAMOUNTPOINT/dotXBMC ]; then
+ mkdir $BOOTMEDIAMOUNTPOINT/dotXBMC
+ fi
+ if [ -d /home/xbmc/.xbmc ]; then
+ if [ -L /home/xbmc/.xbmc ]; then
+ rm /home/xbmc/.xbmc
+ else
+ mv /home/xbmc/.xbmc /home/xbmc/.xbmc.previous
+ fi
+ fi
+ ln -s $BOOTMEDIAMOUNTPOINT/dotXBMC /home/xbmc/.xbmc
+ fi
+ fi
+ fi
+
+ if [ -f /home/xbmc/.xsession ] ; then
+ rm /home/xbmc/.xsession
+ fi
+ if [ -f /tmp/noRestartXBMC ] ; then
+ rm /tmp/noRestartXBMC
+ fi
+end script
+
+script
+ if ! grep -i -q autostart /tmp/xbmcliveParams ; then
+ exit
+ fi
+
+ exec /usr/bin/runXBMC
+end script
+
+post-start script
+ findUSBPort() {
+ local FD=7
+ local tmpFile=$(mktemp)
+ local eof=0
+ local line
+ local usbPort=""
+ local pciDevice=""
+ local inBlock="0"
+ local token=$1
+
+ lshal > $tmpFile
+
+ # Open files.
+ eval exec "$FD<$tmpFile"
+
+ while [ $eof -eq 0 ]
+ do
+ if read line <&$FD; then
+ if [ -n "$(echo $line | grep -i $token)" ]; then
+ if [ "$inBlock" = "0" ]; then
+ inBlock="1"
+ token="linux.sysfs_path"
+ else
+ pciDevice=$(echo $line | awk -F/ '{ print $5}')
+ eof=1
+ fi
+ fi
+ else
+ eof=1
+ fi
+ done
+
+ if [ -n "$pciDevice" ] ; then
+ usbPort=$(cat /proc/acpi/wakeup | grep $pciDevice | awk '{ print $1}')
+ fi
+
+ echo $usbPort
+ }
+
+
+ if grep -q -i setvolume /tmp/xbmcliveParams ; then
+ /usr/bin/setAlsaVolumes
+ fi
+
+ if ! grep -q -i nodiskmount /tmp/xbmcliveParams ; then
+ /usr/bin/diskmounter
+ fi
+
+ if grep -q -i wakeOnUSBRemote /tmp/xbmcliveParams ; then
+ lircDriver=$(dmesg | grep usbcore | grep -i 'lirc' | sed -e "s/.* \(lirc*\)/\1/" | head -n 1)
+ if [ ! -n "$lircDriver" ] ; then
+ # No lirc driver loaded
+ exit
+ fi
+
+ udevTriggerPID=$(pidof udevtrigger)
+ while test -d /proc/$udevTriggerPID; do sleep 1; done;
+
+ usbPort=$(findUSBPort "${lircDriver}")
+
+ if [ -z "$usbPort" ]; then
+ # No USB Remote found
+ exit
+ fi
+
+ usbStatus=`cat /proc/acpi/wakeup | grep $usbport | awk {'print $3}'`
+ if [ "$usbStatus" = "disabled" ]; then
+ echo $usbPort > /proc/acpi/wakeup
+ echo -1 >/sys/module/usbcore/parameters/autosuspend
+ fi
+ fi
+end script
+
+pre-stop script
+ touch /tmp/noRestartXBMC
+ rm /tmp/xbmcliveParams
+
+ # Clean up the console before we switch to it, to avoid text flicker
+ if [ -x /usr/bin/tput ] ; then
+ tput -Tlinux reset > /dev/tty1 || true
+ tput -Tlinux reset > /dev/tty8 || true
+ fi
+
+ # Clear VT 1 & 8 of any console messages
+ clear >/dev/tty1 || true
+ clear >/dev/tty8 || true
+end script