blob: 1380839280953c42994ac67b0cf1910d7449d27d (
plain)
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# xbmc-live
#
# init XBMC environment and starts XBMC in fullscreen (if asked to do so)
description "XBMCLive"
author "Luigi Capriotti"
start on (filesystem and started hal)
# 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
cp $hook /root/hook.sh
chmod 0755 /root/hook.sh
/root/hook.sh
rm -f /root/hook.sh
done
# Generates valid xorg.conf for proprietary drivers if missing
if [ ! -e /etc/X11/xorg.conf ] && [ ! $(grep -i nogenxconf /tmp/xbmcliveParams) ]; then
GPU=$(lspci -nn | grep 0300)
# 10de == NVIDIA
if [ ! "$(echo $GPU | grep 10de)" ]; then
# 1002 == AMD
if [ "$(echo $GPU | grep 1002)" ]; then
# run aticonfig
/usr/bin/aticonfig --initial --sync-vsync=on -f
fi
else
# run nvidia-xconfig
/usr/bin/nvidia-xconfig -s --no-logo --force-generate
fi
fi
# Write fstab entries for ramdisks
if [ $(grep -i tempfs /tmp/xbmcliveParams) ]; then
if [ ! $(grep -i tmpfs /etc/fstab) ] ; then
echo "tmpfs /var/log tmpfs defaults 0 0" >> /etc/fstab
echo "tmpfs /tmp tmpfs defaults 0 0" >> /etc/fstab
echo "tmpfs /var/tmp tmpfs defaults 0 0" >> /etc/fstab
fi
fi
if [ ! `mount | grep iso9660` ]; then
if [ ! $(grep -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 install /tmp/xbmcliveParams) ] ; then
exit
fi
if [ ! $(grep -i autostart /tmp/xbmcliveParams) ] ; then
exit
fi
# TODO check if needed
if [ "$(pidof usplash)" ] ; then
stop usplash
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 -i setvolume /tmp/xbmcliveParams) ] ; then
/usr/bin/setAlsaVolumes
fi
if [ ! $(grep -i nodiskmount /tmp/xbmcliveParams) ] ; then
/usr/bin/diskmounter
fi
if [ $(grep -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
|