Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (39 sloc) 1.4 KB
#!/bin/bash
clear >/dev/tty1 || true
clear >/dev/tty7 || true
kernelParams=$(cat /proc/cmdline)
subString=${kernelParams##*xbmc=}
xbmcParams=${subString%% *}
if grep "boot=live" /proc/cmdline ; then
# Relies on init scripts to mount boot device on a specified directory
BOOTMEDIAMOUNTPOINT="/live/image"
fi
BOOTHOOKSDIRECTORY="/usr/lib/xbmc"
xbmcUser=xbmc
# Read configuration variable file if it is present
[ -r /etc/default/xbmc-live ] && . /etc/default/xbmc-live
if ! getent passwd $xbmcUser >/dev/null; then
xbmcUser=$(getent passwd 1000 | sed -e 's/\:.*//')
fi
# Executes pre-hooks (if any) in the System "Hooks" directory
for hook in $(ls -1 $BOOTHOOKSDIRECTORY/live.d/*.sh)
do
bash $hook $BOOTMEDIAMOUNTPOINT $XBMC_PARAMS
done
# Executes pre-hooks (if any) in the user "Hooks" directory
for hook in $(ls -1 /home/$xbmcUser/.xbmc/live.d/*.sh)
do
bash $hook $BOOTMEDIAMOUNTPOINT $XBMC_PARAMS
done
# if strings are NOT the same the token is part of the parameters list
# here we want to stop script if the token is NOT there
activationToken="autostart"
if [ "$xbmcParams" = "${xbmcParams%$activationToken*}" ] ; then
rm /home/$xbmcUser/.xsession
exit 1
fi
echo "#!/bin/sh" > /home/$xbmcUser/.xsession
echo "clear >/dev/tty1 || true" >> /home/$xbmcUser/.xsession
echo "exec /usr/bin/xbmc --standalone" >> /home/$xbmcUser/.xsession
chown $xbmcUser:$xbmcUser /home/$xbmcUser/.xsession
/usr/bin/xinit $@