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

Commit 5bfb221

Browse files
committed
Merge branch 'master' of https://github.com/tvdzwan/hyperion.git
2 parents a2b38c6 + 6006e57 commit 5bfb221

File tree

5 files changed

+131
-14
lines changed

5 files changed

+131
-14
lines changed

bin/copy_binaries_to_deploy.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ tar --create --verbose --gzip --absolute-names --show-transformed-names \
1818
--transform "s:$builddir/bin/:hyperion/bin/:" \
1919
--transform "s:$repodir/effects/:hyperion/effects/:" \
2020
--transform "s:$repodir/config/:hyperion/config/:" \
21+
--transform "s:$repodir/bin/hyperion.init.sh:hyperion/init.d/hyperion.init.sh:" \
2122
--transform "s://:/:g" \
2223
"$builddir/bin/hyperiond" \
2324
"$builddir/bin/hyperion-remote" \
2425
"$builddir/bin/gpio2spi" \
2526
"$builddir/bin/dispmanx2png" \
2627
"$repodir/effects/"* \
28+
"$repodir/bin/hyperion.init.sh" \
2729
"$repodir/config/hyperion.config.json"

bin/hyperion.init.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# Hyperion daemon
3+
# description: Hyperion daemon
4+
# processname: hyperiond
5+
6+
DAEMON=hyperiond
7+
DAEMONOPTS="/etc/hyperion.config.json"
8+
DAEMON_PATH="/usr/bin"
9+
10+
NAME=$DEAMON
11+
DESC="Hyperion ambilight server"
12+
PIDFILE=/var/run/$NAME.pid
13+
SCRIPTNAME=/etc/init.d/$NAME
14+
15+
case "$1" in
16+
start)
17+
printf "%-50s" "Starting $NAME..."
18+
cd $DAEMON_PATH
19+
PID=`$DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`
20+
#echo "Saving PID" $PID " to " $PIDFILE
21+
if [ -z $PID ]; then
22+
printf "%s\n" "Fail"
23+
else
24+
echo $PID > $PIDFILE
25+
printf "%s\n" "Ok"
26+
fi
27+
;;
28+
status)
29+
printf "%-50s" "Checking $NAME..."
30+
if [ -f $PIDFILE ]; then
31+
PID=`cat $PIDFILE`
32+
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
33+
printf "%s\n" "Process dead but pidfile exists"
34+
else
35+
echo "Running"
36+
fi
37+
else
38+
printf "%s\n" "Service not running"
39+
fi
40+
;;
41+
stop)
42+
printf "%-50s" "Stopping $NAME"
43+
PID=`cat $PIDFILE`
44+
cd $DAEMON_PATH
45+
if [ -f $PIDFILE ]; then
46+
kill -HUP $PID
47+
printf "%s\n" "Ok"
48+
rm -f $PIDFILE
49+
else
50+
printf "%s\n" "pidfile not found"
51+
fi
52+
;;
53+
54+
restart)
55+
$0 stop
56+
$0 start
57+
;;
58+
59+
*)
60+
echo "Usage: $0 {status|start|stop|restart}"
61+
exit 1
62+
esac

bin/install_hyperion.sh

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,95 @@
11
#!/bin/sh
22

3+
# Make sure /sbin is on the path (for service to find sub scripts)
4+
PATH="/sbin:$PATH"
5+
36
# Script for downloading and installing the latest Hyperion release
47

5-
# Find out if we are on XBian
8+
# Find out if we are on Raspbmc
69
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`
716

817
# 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)
1019
if [ $BOBLIGHT_PROCNR -eq 1 ];
1120
then
1221
echo 'Found running instance of boblight. Please stop boblight via XBMC menu before installing hyperion'
1322
exit
1423
fi
1524

1625
# 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
1832

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
2145

2246
# 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
2551

2652
# create link to the gpio changer (gpio->spi)
27-
if [ $IS_XBIAN -eq 0 ]; then
53+
if [ $IS_RASPBMC -eq 1 ]; then
2854
ln -fs /opt/hyperion/bin/gpio2spi /usr/bin/gpio2spi
2955
fi
3056

3157
# 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+
3366

3467
# 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
3988
fi
4089

4190
# 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
6.71 MB
Binary file not shown.

deploy/hyperion.tar.gz

396 KB
Binary file not shown.

0 commit comments

Comments
 (0)