mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 13:46:49 +00:00
xbmc: add initial systemd support
Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
parent
1bfe7bba0d
commit
0ece1359d9
@ -1,139 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
# 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 XBMC
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
}
|
|
||||||
|
|
||||||
LIRCDEV="/var/run/lirc/lircd"
|
|
||||||
[ -e /var/run/lirc/lircd.irtrans ] && LIRCDEV="/var/run/lirc/lircd.irtrans"
|
|
||||||
XBMC_ARGS="--standalone -fs --lircdev $LIRCDEV"
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# hack: make addon-bins executable
|
|
||||||
chmod +x /storage/.xbmc/addons/*/bin/* > /dev/null 2>&1
|
|
||||||
|
|
||||||
# hack: update RSSnews.xml in userdata
|
|
||||||
if [ -f /storage/.xbmc/userdata/RssFeeds.xml ]; then
|
|
||||||
sed -e "s,http://openelec.tv/news?format=feed&type=rss,http://feeds.openelec.tv/news,g" \
|
|
||||||
-i /storage/.xbmc/userdata/RssFeeds.xml
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
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
|
|
@ -459,15 +459,20 @@ make_target() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
post_makeinstall_target() {
|
post_makeinstall_target() {
|
||||||
|
rm -rf $INSTALL/usr/bin/xbmc
|
||||||
|
rm -rf $INSTALL/usr/bin/xbmc-standalone
|
||||||
|
|
||||||
|
mkdir -p $INSTALL/usr/lib/xbmc
|
||||||
|
cp $PKG_DIR/scripts/xbmc-config $INSTALL/usr/lib/xbmc
|
||||||
|
cp $PKG_DIR/scripts/xbmc-hacks $INSTALL/usr/lib/xbmc
|
||||||
|
cp $PKG_DIR/scripts/xbmc-sources $INSTALL/usr/lib/xbmc
|
||||||
|
|
||||||
mkdir -p $INSTALL/usr/bin
|
mkdir -p $INSTALL/usr/bin
|
||||||
cp $PKG_DIR/scripts/cputemp $INSTALL/usr/bin
|
cp $PKG_DIR/scripts/cputemp $INSTALL/usr/bin
|
||||||
cp $PKG_DIR/scripts/gputemp $INSTALL/usr/bin
|
cp $PKG_DIR/scripts/gputemp $INSTALL/usr/bin
|
||||||
cp $PKG_DIR/scripts/setwakeup.sh $INSTALL/usr/bin
|
cp $PKG_DIR/scripts/setwakeup.sh $INSTALL/usr/bin
|
||||||
cp tools/EventClients/Clients/XBMC\ Send/xbmc-send.py $INSTALL/usr/bin/xbmc-send
|
cp tools/EventClients/Clients/XBMC\ Send/xbmc-send.py $INSTALL/usr/bin/xbmc-send
|
||||||
|
|
||||||
rm -rf $INSTALL/usr/bin/xbmc
|
|
||||||
rm -rf $INSTALL/usr/bin/xbmc-standalone
|
|
||||||
|
|
||||||
if [ ! "$DISPLAYSERVER" = "xorg-server" ]; then
|
if [ ! "$DISPLAYSERVER" = "xorg-server" ]; then
|
||||||
rm -rf $INSTALL/usr/lib/xbmc/xbmc-xrandr
|
rm -rf $INSTALL/usr/lib/xbmc/xbmc-xrandr
|
||||||
fi
|
fi
|
||||||
@ -535,3 +540,17 @@ post_makeinstall_target() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post_install() {
|
||||||
|
# link default.target to xbmc.target
|
||||||
|
ln -sf xbmc.target $INSTALL/lib/systemd/system/default.target
|
||||||
|
|
||||||
|
enable_service xbmc-autostart.service
|
||||||
|
enable_service xbmc-cleanlogs.service
|
||||||
|
enable_service xbmc-config.service
|
||||||
|
enable_service xbmc-hacks.service
|
||||||
|
enable_service xbmc-sources.service
|
||||||
|
enable_service xbmc-halt.service
|
||||||
|
enable_service xbmc-poweroff.service
|
||||||
|
enable_service xbmc-reboot.service
|
||||||
|
enable_service xbmc.service
|
||||||
|
}
|
||||||
|
34
packages/mediacenter/xbmc/scripts/xbmc-config
Executable file
34
packages/mediacenter/xbmc/scripts/xbmc-config
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
################################################################################
|
||||||
|
# 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
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
. /etc/profile
|
||||||
|
|
||||||
|
if [ -e /var/run/lirc/lircd.irtrans ]; then
|
||||||
|
XBMC_ARGS="--lircdev /var/run/lirc/lircd.irtrans"
|
||||||
|
else
|
||||||
|
XBMC_ARGS="--lircdev /var/run/lirc/lircd"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$DEBUG" = yes ]; then
|
||||||
|
XBMC_ARGS="$XBMC_ARGS --debug"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "XBMC_ARGS=\"$XBMC_ARGS\"" > /run/xbmc/xbmc.conf
|
29
packages/mediacenter/xbmc/scripts/xbmc-hacks
Executable file
29
packages/mediacenter/xbmc/scripts/xbmc-hacks
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
################################################################################
|
||||||
|
# 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
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# hack: make addon-bins executable
|
||||||
|
chmod +x /storage/.xbmc/addons/*/bin/*
|
||||||
|
|
||||||
|
# hack: update RSSnews.xml in userdata
|
||||||
|
if [ -f /storage/.xbmc/userdata/RssFeeds.xml ]; then
|
||||||
|
sed -e "s,http://openelec.tv/news?format=feed&type=rss,http://feeds.openelec.tv/news,g" \
|
||||||
|
-i /storage/.xbmc/userdata/RssFeeds.xml
|
||||||
|
fi
|
7
packages/mediacenter/xbmc/init.d/92_setup-xbmc → packages/mediacenter/xbmc/scripts/xbmc-sources
Normal file → Executable file
7
packages/mediacenter/xbmc/init.d/92_setup-xbmc → packages/mediacenter/xbmc/scripts/xbmc-sources
Normal file → Executable file
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
################################################################################
|
################################################################################
|
||||||
# This file is part of OpenELEC - http://www.openelec.tv
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
|
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
|
||||||
@ -18,11 +19,7 @@
|
|||||||
# http://www.gnu.org/copyleft/gpl.html
|
# http://www.gnu.org/copyleft/gpl.html
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# setup XBMC
|
. /etc/profile
|
||||||
#
|
|
||||||
# runlevels: openelec
|
|
||||||
|
|
||||||
progress "setup XBMC"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# setup XBMC sources
|
# setup XBMC sources
|
13
packages/mediacenter/xbmc/system.d/xbmc-autostart.service
Normal file
13
packages/mediacenter/xbmc/system.d/xbmc-autostart.service
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC user autostart script
|
||||||
|
Before=xbmc.service
|
||||||
|
After=graphical.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=HOME=/storage
|
||||||
|
ExecStart=-/bin/sh -c /storage/.config/autostart.sh
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=xbmc.service
|
13
packages/mediacenter/xbmc/system.d/xbmc-cleanlogs.service
Normal file
13
packages/mediacenter/xbmc/system.d/xbmc-cleanlogs.service
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC clean debug logs
|
||||||
|
ConditionKernelCommandLine=!debugging
|
||||||
|
Before=xbmc.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=HOME=/storage
|
||||||
|
ExecStart=-/bin/sh -c rm -rf /storage/.xbmc/userdata/addon_data/*/*.log /storage/.xbmc/userdata/addon_data/*/log/*
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=xbmc.service
|
12
packages/mediacenter/xbmc/system.d/xbmc-config.service
Normal file
12
packages/mediacenter/xbmc/system.d/xbmc-config.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC configfile writer
|
||||||
|
Before=xbmc.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=HOME=/storage
|
||||||
|
ExecStart=/usr/lib/xbmc/xbmc-config
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=xbmc.service
|
12
packages/mediacenter/xbmc/system.d/xbmc-hacks.service
Normal file
12
packages/mediacenter/xbmc/system.d/xbmc-hacks.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC hacks
|
||||||
|
Before=xbmc.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=HOME=/storage
|
||||||
|
ExecStart=/usr/lib/xbmc/xbmc-hacks
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=xbmc.service
|
14
packages/mediacenter/xbmc/system.d/xbmc-halt.service
Normal file
14
packages/mediacenter/xbmc/system.d/xbmc-halt.service
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC halt script
|
||||||
|
After=xbmc.service
|
||||||
|
Before=halt.service
|
||||||
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=HOME=/storage
|
||||||
|
ExecStart=-/bin/sh /storage/.config/shutdown.sh halt
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=halt.target
|
14
packages/mediacenter/xbmc/system.d/xbmc-poweroff.service
Normal file
14
packages/mediacenter/xbmc/system.d/xbmc-poweroff.service
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC poweroff script
|
||||||
|
After=xbmc.service
|
||||||
|
Before=poweroff.service
|
||||||
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=HOME=/storage
|
||||||
|
ExecStart=-/bin/sh /storage/.config/shutdown.sh poweroff
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=poweroff.target
|
14
packages/mediacenter/xbmc/system.d/xbmc-reboot.service
Normal file
14
packages/mediacenter/xbmc/system.d/xbmc-reboot.service
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC reboot script
|
||||||
|
After=xbmc.service
|
||||||
|
Before=reboot.service
|
||||||
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=HOME=/storage
|
||||||
|
ExecStart=-/bin/sh /storage/.config/shutdown.sh reboot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=reboot.target
|
12
packages/mediacenter/xbmc/system.d/xbmc-sources.service
Normal file
12
packages/mediacenter/xbmc/system.d/xbmc-sources.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC sources Setup
|
||||||
|
Before=xbmc.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
Environment=HOME=/storage
|
||||||
|
ExecStart=/usr/lib/xbmc/xbmc-sources
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=xbmc.service
|
16
packages/mediacenter/xbmc/system.d/xbmc.service
Normal file
16
packages/mediacenter/xbmc/system.d/xbmc.service
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC Media Center
|
||||||
|
After=graphical.target
|
||||||
|
Requires=graphical.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=DISPLAY=:0.0
|
||||||
|
Environment=SDL_MOUSE_RELATIVE=0
|
||||||
|
Environment=HOME=/storage
|
||||||
|
EnvironmentFile=-/run/xbmc/xbmc.conf
|
||||||
|
ExecStart=/usr/lib/xbmc/xbmc.bin --standalone -fs $XBMC_ARGS
|
||||||
|
KillMode=process
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=xbmc.target
|
9
packages/mediacenter/xbmc/system.d/xbmc.target
Normal file
9
packages/mediacenter/xbmc/system.d/xbmc.target
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=XBMC Mediacenter Interface
|
||||||
|
Requires=multi-user.target graphical.target
|
||||||
|
After=graphical.target
|
||||||
|
Conflicts=rescue.target
|
||||||
|
AllowIsolate=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
Alias=default.target
|
@ -18,12 +18,4 @@
|
|||||||
# http://www.gnu.org/copyleft/gpl.html
|
# http://www.gnu.org/copyleft/gpl.html
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# starting XBMC
|
d /run/xbmc 0755 root root - -
|
||||||
#
|
|
||||||
# runlevels: openelec
|
|
||||||
|
|
||||||
if [ ! "$DEBUG" = "yes" ]; then
|
|
||||||
progress "clean up log files"
|
|
||||||
rm -f /storage/.xbmc/userdata/addon_data/*/*.log 2>/dev/null
|
|
||||||
rm -rf /storage/.xbmc/userdata/addon_data/*/log/* 2>/dev/null
|
|
||||||
fi
|
|
Loading…
x
Reference in New Issue
Block a user