|
1 | 1 | #!/bin/sh
|
2 | 2 |
|
| 3 | +# Make sure /sbin is on the path (for service to find sub scripts) |
| 4 | +PATH="/sbin:$PATH" |
| 5 | + |
3 | 6 | # Script for downloading and installing the latest Hyperion release
|
4 | 7 |
|
5 |
| -# Find out if we are on XBian |
| 8 | +# Find out if we are on Raspbmc |
6 | 9 | IS_XBIAN=`cat /etc/issue | grep XBian | wc -l`
|
| 10 | +IS_RASPBMC=`cat /etc/issue | grep Raspbmc | wc -l` |
| 11 | +IS_OPENELEC=`cat /etc/issue | grep -m 1 OpenELEC | wc -l` |
| 12 | + |
| 13 | +# check which init script we should use |
| 14 | +USE_INITCTL=`which /sbin/initctl | wc -l` |
| 15 | +USE_SERVICE=`which /usr/sbin/service | wc -l` |
7 | 16 |
|
8 | 17 | # Make sure that the boblight daemon is no longer running
|
9 |
| -BOBLIGHT_PROCNR=$(ps -e | grep "boblight" | wc -l) |
| 18 | +BOBLIGHT_PROCNR=$(pidof boblightd | wc -l) |
10 | 19 | if [ $BOBLIGHT_PROCNR -eq 1 ];
|
11 | 20 | then
|
12 | 21 | echo 'Found running instance of boblight. Please stop boblight via XBMC menu before installing hyperion'
|
13 | 22 | exit
|
14 | 23 | fi
|
15 | 24 |
|
16 | 25 | # Stop hyperion daemon if it is running
|
17 |
| -/sbin/initctl stop hyperion |
| 26 | +# Start the hyperion daemon |
| 27 | +if [ $USE_INITCTL -eq 1 ]; then |
| 28 | + /sbin/initctl stop hyperion |
| 29 | +elif [ $USE_SERVICE -eq 1 ]; then |
| 30 | + /usr/sbin/service hyperion stop |
| 31 | +fi |
18 | 32 |
|
19 |
| -# Get and extract the Hyperion binaries and effects to /opt |
20 |
| -wget https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.tar.gz -O - | tar -C /opt -xz |
| 33 | +# Get and extract the Hyperion binaries and effects |
| 34 | +echo 'Downloading hyperion' |
| 35 | +if [ $IS_OPENELEC -eq 1 ]; then |
| 36 | + # OpenELEC has a readonly file system. Use alternative location |
| 37 | + curl --get https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.tar.gz | tar -C /storage -xz |
| 38 | + curl --get https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.deps.openelec-rpi.tar.gz | tar -C /storage/hyperion/bin -xz |
| 39 | + |
| 40 | + # modify the default config to have a correct effect path |
| 41 | + sed -i 's:/opt:/storage:g' /storage/hyperion/config/hyperion.config.json |
| 42 | +else |
| 43 | + wget https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.tar.gz -O - | tar -C /opt -xz |
| 44 | +fi |
21 | 45 |
|
22 | 46 | # create links to the binaries
|
23 |
| -ln -fs /opt/hyperion/bin/hyperiond /usr/bin/hyperiond |
24 |
| -ln -fs /opt/hyperion/bin/hyperion-remote /usr/bin/hyperion-remote |
| 47 | +if [ $IS_OPENELEC -ne 1 ]; then |
| 48 | + ln -fs /opt/hyperion/bin/hyperiond /usr/bin/hyperiond |
| 49 | + ln -fs /opt/hyperion/bin/hyperion-remote /usr/bin/hyperion-remote |
| 50 | +fi |
25 | 51 |
|
26 | 52 | # create link to the gpio changer (gpio->spi)
|
27 |
| -if [ $IS_XBIAN -eq 0 ]; then |
| 53 | +if [ $IS_RASPBMC -eq 1 ]; then |
28 | 54 | ln -fs /opt/hyperion/bin/gpio2spi /usr/bin/gpio2spi
|
29 | 55 | fi
|
30 | 56 |
|
31 | 57 | # Copy a link to the hyperion configuration file to /etc
|
32 |
| -ln -s /opt/hyperion/config/hyperion.config.json /etc/hyperion.config.json |
| 58 | +if [ $IS_OPENELEC -eq 1 ]; then |
| 59 | + # copy to alternate location, because of readonly file system |
| 60 | + # /storage/.config is available as samba share. A symbolic link would not be working |
| 61 | + false | cp -i /storage/hyperion/config/hyperion.config.json /storage/.config/hyperion.config.json 2>/dev/null |
| 62 | +else |
| 63 | + ln -s /opt/hyperion/config/hyperion.config.json /etc/hyperion.config.json |
| 64 | +fi |
| 65 | + |
33 | 66 |
|
34 | 67 | # Copy the service control configuration to /etc/int
|
35 |
| -if [ $IS_XBIAN -eq 0 ]; then |
36 |
| - wget -N https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.conf -P /etc/init/ |
37 |
| -else |
38 |
| - wget -N https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.xbian.conf -O /etc/init/hyperion.conf |
| 68 | +if [ $USE_INITCTL -eq 1 ]; then |
| 69 | + echo 'Installing initctl script' |
| 70 | + if [ $IS_RASPBMC -eq 1 ]; then |
| 71 | + wget -N https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.conf -P /etc/init/ |
| 72 | + else |
| 73 | + wget -N https://raw.github.com/tvdzwan/hyperion/master/deploy/hyperion.xbian.conf -O /etc/init/hyperion.conf |
| 74 | + fi |
| 75 | +elif [ $USE_SERVICE -eq 1 ]; then |
| 76 | + echo 'Installing startup script in init.d' |
| 77 | + # place startup script in init.d and add it to upstart |
| 78 | + ln -fs /opt/hyperion/init.d/hyperion.init.sh /etc/init.d/hyperion |
| 79 | + chmod +x /etc/init.d/hyperion |
| 80 | + update-rc.d hyperion defaults 98 02 |
| 81 | +elif [ $IS_OPENELEC -eq 1 ]; then |
| 82 | + # only add to start script if hyperion is not present yet |
| 83 | + if [ `cat /storage/.config/autostart.sh 2>/dev/null | grep hyperiond | wc -l` -eq 0 ]; then |
| 84 | + echo 'Adding Hyperion to autostart script' |
| 85 | + echo "/storage/hyperion/bin/hyperiond.sh /storage/.config/hyperion.config.json > /dev/null 2>&1 &" >> /storage/.config/autostart.sh |
| 86 | + chmod +x /storage/.config/autostart.sh |
| 87 | + fi |
39 | 88 | fi
|
40 | 89 |
|
41 | 90 | # Start the hyperion daemon
|
42 |
| -/sbin/initctl start hyperion |
| 91 | +if [ $USE_INITCTL -eq 1 ]; then |
| 92 | + /sbin/initctl start hyperion |
| 93 | +elif [ $USE_SERVICE -eq 1 ]; then |
| 94 | + /usr/sbin/service hyperion start |
| 95 | +fi |
0 commit comments