forked from OpenELEC/OpenELEC.tv
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path93_plexht
More file actions
177 lines (152 loc) · 4.91 KB
/
Copy path93_plexht
File metadata and controls
177 lines (152 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2012 Stephan Raue (stephan@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, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
# starting PlexHT
#
# runlevels: openelec
# prevent restrating XBMC at reboot or shutdown
LOCKDIR="/var/lock/"
LOCKFILE="xbmc.disabled"
[ -f "$LOCKDIR/$LOCKFILE" ] && rm -f "$LOCKDIR/$LOCKFILE" &
# needed functions
add_omit_pids() {
omit_pids="$omit_pids -o $1"
}
safe_shutdown () {
touch "$LOCKDIR/$LOCKFILE"
SHUTDOWN="/storage/.config/shutdown.sh"
if [ -f $SHUTDOWN ]; then
echo '!!! SHUTDOWN script detected !!!' | logger -t shutdown.sh $1
cat "$SHUTDOWN" | logger -t shutdown.sh
echo '!!! -End of shutdown script- !!!' | logger -t shutdown.sh $1
sh $SHUTDOWN $1
fi
add_omit_pids $(pidof connmand)
add_omit_pids $(pidof dbus-daemon)
killall5 -15 $omit_pids
for seq in `seq 1 10` ; do
usleep 500000
clear > /dev/tty1
killall5 -18 $omit_pids || break
done
sync
umount -a >/dev/null 2>&1
if [ $1 = "reboot" ]; then
reboot
elif [ $1 = "poweroff" ]; then
poweroff -f
fi
}
XBMC_BIN_BUILTIN=/usr/lib/plexhometheater/plexhometheater
XBMC_HOME_PATH_BUILTIN=/usr/share/xbmc
PHT_DEBUG_PATH=$HOME/debug/plexht
PHT_DEBUG_HOME_PATH="$PHT_DEBUG_PATH/xbmc"
LIRCDEV="/var/run/lirc/lircd"
[ -e /var/run/lirc/lircd.irtrans ] && LIRCDEV="/var/run/lirc/lircd.irtrans"
XBMC_ARGS="--standalone -fs --lircdev $LIRCDEV"
if [ ! -f /storage/.bashrc ]; then
touch /storage/.bashrc
echo "export XBMC_HOME=/storage/debug/plexht" >> /storage/.bashrc
else
if ! grep -q "export XBMC_HOME=/storage/debug/plexht" /storage/.bashrc; then
echo "export XBMC_HOME=/storage/debug/plexht" >> /storage/.bashrc
fi
fi
if [ "$DEBUG" = yes ]; then
XBMC_ARGS="$XBMC_ARGS --debug"
fi
progress "starting XBMC"
# hack for Boxee Remote
if grep -q "Vendor=0471 Product=20d9" /proc/bus/input/devices; then
export SDL_MOUSE_RELATIVE=0
fi
if [ ! -f $HOME/.plexht/bootstrapped ];then
[ ! -d $HOME/.plexht/userdata ] && mkdir -p $HOME/.plexht/userdata
touch $HOME/.plexht/bootstrapped
cp /usr/share/xbmc/guisettings.xml $HOME/.plexht/userdata/
cp /usr/share/xbmc/advancedsettings.xml $HOME/.plexht/userdata/
fi
# hack: make addon-bins executable
chmod +x /storage/.plexht/addons/*/bin/* > /dev/null 2>&1
# wait for dbus to start
wait_for_dbus
# wait for network
wait_for_inet_addr
# wait for udevadm settle to finish
wait_for_udevadm_settle
# starting autostart script (will be removed later again, dont use it!!!)
AUTOSTART="/storage/.config/autostart.sh"
if [ -f $AUTOSTART ]; then
echo '!!! AUTOSTART script detected !!!' | logger -t Boot
cat "$AUTOSTART" | logger -t Boot
echo '!!! -End of autostart script- !!!' | logger -t Boot
sh $AUTOSTART
fi
# waiting for Xorg to start
wait_for_xorg
# set cpu's to 'conservative'
( usleep 15000000
progress "set cpu's to 'ondemand'"
cpupower frequency-set -g ondemand > /dev/null 2>&1
)&
# starting XBMC
usleep $XBMC_STARTDELAY
while true; do
while [ -f "$LOCKDIR/$LOCKFILE" ]; do
usleep 250000
done
if [ -f "$PHT_DEBUG_PATH/plexhometheater" ]; then
XBMC_BIN="$PHT_DEBUG_PATH/plexhometheater"
else
XBMC_BIN="$XBMC_BIN_BUILTIN"
fi
if [ -d "$PHT_DEBUG_HOME_PATH" ]; then
XBMC_HOME_PATH="$PHT_DEBUG_HOME_PATH"
else
XBMC_HOME_PATH="$XBMC_HOME_PATH_BUILTIN"
fi
cd /storage
XBMC_HOME="$XBMC_HOME_PATH"
export XBMC_HOME
export XBMC_BIN
export XBMC_ARGS
ulimit -c unlimited
echo -n 1 | /bin/tee /proc/sys/fs/suid_dumpable
/usr/bin/plexht > /dev/null 2>&1
RET=$?
case "$RET" in
0)
safe_shutdown poweroff
;;
64)
safe_shutdown poweroff
;;
66)
safe_shutdown reboot
;;
255)
echo "Abnormal Exit. Exited with code $RET"
echo "is Xorg running? check /var/log/Xorg.log"
;;
*)
echo "Abnormal Exit. Exited with code $RET"
;;
esac
usleep 250000
done