Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 6a92916

Browse files
committed
make install script work with OpenELEC
1 parent 855c589 commit 6a92916

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

bin/install_hyperion.sh

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
# Find out if we are on Raspbmc
66
IS_XBIAN=`cat /etc/issue | grep XBian | wc -l`
77
IS_RASPBMC=`cat /etc/issue | grep Raspbmc | wc -l`
8+
IS_OPENELEC=`cat /etc/issue | grep -m 1 OpenELEC | wc -l`
89

910
# check which init script we should use
1011
USE_INITCTL=`which /sbin/initctl | wc -l`
12+
USE_SERVICE=`which /usr/sbin/service | wc -l`
1113

1214
# Make sure that the boblight daemon is no longer running
13-
BOBLIGHT_PROCNR=$(ps -e | grep "boblight" | wc -l)
15+
BOBLIGHT_PROCNR=$(pidof boblightd | wc -l)
1416
if [ $BOBLIGHT_PROCNR -eq 1 ];
1517
then
1618
echo 'Found running instance of boblight. Please stop boblight via XBMC menu before installing hyperion'
@@ -21,42 +23,70 @@ fi
2123
# Start the hyperion daemon
2224
if [ $USE_INITCTL -eq 1 ]; then
2325
/sbin/initctl stop hyperion
24-
else
26+
elif [ $USE_SERVICE -eq 1 ]; then
2527
/usr/sbin/service hyperion stop
2628
fi
2729

28-
# Get and extract the Hyperion binaries and effects to /opt
29-
wget https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.tar.gz -O - | tar -C /opt -xz
30+
# Get and extract the Hyperion binaries and effects
31+
echo 'Downloading hyperion'
32+
if [ $IS_OPENELEC -eq 1 ]; then
33+
# OpenELEC has a readonly file system. Use alternative location
34+
curl --get https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.tar.gz | tar -C /storage -xz
35+
curl --get https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.deps.openelec-rpi.tar.gz | tar -C /storage/hyperion/bin -xz
36+
37+
# modify the default config to have a correct effect path
38+
sed -i 's:/opt:/storage:g' /storage/hyperion/config/hyperion.config.json
39+
else
40+
wget https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.tar.gz -O - | tar -C /opt -xz
41+
fi
3042

3143
# create links to the binaries
32-
ln -fs /opt/hyperion/bin/hyperiond /usr/bin/hyperiond
33-
ln -fs /opt/hyperion/bin/hyperion-remote /usr/bin/hyperion-remote
44+
if [ $IS_OPENELEC -ne 1 ]; then
45+
ln -fs /opt/hyperion/bin/hyperiond /usr/bin/hyperiond
46+
ln -fs /opt/hyperion/bin/hyperion-remote /usr/bin/hyperion-remote
47+
fi
3448

3549
# create link to the gpio changer (gpio->spi)
3650
if [ $IS_RASPBMC -eq 1 ]; then
3751
ln -fs /opt/hyperion/bin/gpio2spi /usr/bin/gpio2spi
3852
fi
3953

4054
# Copy a link to the hyperion configuration file to /etc
41-
ln -s /opt/hyperion/config/hyperion.config.json /etc/hyperion.config.json
55+
if [ $IS_OPENELEC -eq 1 ]; then
56+
# copy to alternate location, because of readonly file system
57+
# /storage/.config is available as samba share. A symbolic link would not be working
58+
false | cp -i /storage/hyperion/config/hyperion.config.json /storage/.config/hyperion.config.json 2>/dev/null
59+
else
60+
ln -s /opt/hyperion/config/hyperion.config.json /etc/hyperion.config.json
61+
fi
62+
4263

4364
# Copy the service control configuration to /etc/int
4465
if [ $USE_INITCTL -eq 1 ]; then
66+
echo 'Installing initctl script'
4567
if [ $IS_RASPBMC -eq 1 ]; then
4668
wget -N https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.conf -P /etc/init/
4769
else
4870
wget -N https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.xbian.conf -O /etc/init/hyperion.conf
4971
fi
50-
else
72+
elif [ $USE_SERVICE -eq 1 ]; then
73+
echo 'Installing startup script in init.d'
5174
# place startup script in init.d and add it to upstart
5275
ln -fs /opt/hyperion/init.d/hyperion.init.sh /etc/init.d/hyperion
5376
chmod +x /etc/init.d/hyperion
5477
update-rc.d hyperion defaults 98 02
78+
elif [ $IS_OPENELEC -eq 1 ]; then
79+
# only add to start script if hyperion is not present yet
80+
if [ `cat /storage/.config/autostart.sh 2>/dev/null | grep hyperiond | wc -l` -eq 0 ]; then
81+
echo 'Adding Hyperion to autostart script'
82+
echo "/storage/hyperion/bin/hyperiond.sh /storage/.config/hyperion.config.json > /dev/null 2>&1 &" >> /storage/.config/autostart.sh
83+
chmod +x /storage/.config/autostart.sh
84+
fi
5585
fi
5686

5787
# Start the hyperion daemon
5888
if [ $USE_INITCTL -eq 1 ]; then
5989
/sbin/initctl start hyperion
60-
else
90+
elif [ $USE_SERVICE -eq 1 ]; then
6191
/usr/sbin/service hyperion start
6292
fi

0 commit comments

Comments
 (0)