2016-05-24 19:56:43 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
install_file()
|
|
|
|
{
|
|
|
|
src="$1"
|
|
|
|
dest="$2"
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
if [ ! -e "$dest" ]
|
|
|
|
cp "$src" "${dest}"
|
2016-06-02 19:54:37 +02:00
|
|
|
return 1
|
2017-02-08 14:36:28 +01:00
|
|
|
else
|
|
|
|
echo "--> Service file already exists, skip creation"
|
|
|
|
return 0
|
2016-05-24 19:56:43 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-20 16:37:45 +02:00
|
|
|
echo "--- hyperion ambient light postinstall ---"
|
2016-05-24 19:56:43 +02:00
|
|
|
echo "- install configuration template"
|
|
|
|
mkdir -p /etc/hyperion
|
2017-02-08 14:36:28 +01:00
|
|
|
mkdir -p /usr/share/hyperion/custom-effects
|
|
|
|
|
|
|
|
#check system
|
|
|
|
CPU_RPI=`grep -m1 -c 'BCM2708\|BCM2709\|BCM2710\|BCM2835' /proc/cpuinfo`
|
|
|
|
CPU_X32X64=`uname -m | grep 'x86_32\|i686\|x86_64' | wc -l`
|
|
|
|
|
|
|
|
#Check for a bootloader as Berryboot
|
|
|
|
BOOT_BERRYBOOT=$(grep -m1 -c '\(/var/media\|/media/pi\)/berryboot' /etc/mtab)
|
|
|
|
|
|
|
|
#get current system ip + add default port
|
|
|
|
address=$(ip -o -4 a | awk '$2 == "eth0" { gsub(/\/.*/, "", $4); print $4 }')":8099"
|
2016-05-24 19:56:43 +02:00
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
#check if hyperion is running
|
2016-06-02 19:54:37 +02:00
|
|
|
HYPERION_RUNNING=false
|
|
|
|
pgrep hyperiond > /dev/null 2>&1 && HYPERION_RUNNING=true
|
|
|
|
|
|
|
|
start_msg=""
|
|
|
|
restart_msg=""
|
|
|
|
SERVICE_POSTFIX=""
|
|
|
|
|
2016-08-20 16:37:45 +02:00
|
|
|
if grep -m1 systemd /proc/1/comm > /dev/null
|
2016-06-02 19:54:37 +02:00
|
|
|
then
|
2017-02-08 14:36:28 +01:00
|
|
|
echo "--> init deamon: systemd"
|
2016-05-24 19:56:43 +02:00
|
|
|
# systemd
|
2017-02-08 14:36:28 +01:00
|
|
|
$HYPERION_RUNNING && systemctl stop hyperiond 2> /dev/null
|
|
|
|
install_file /usr/share/hyperion/service/hyperion.systemd /etc/systemd/system/hyperiond.service && systemctl -q enable hyperiond.service
|
|
|
|
start_msg="--> systemctl start hyperiond"
|
|
|
|
systemctl start hyperiond
|
2016-06-02 19:54:37 +02:00
|
|
|
|
2016-08-20 16:37:45 +02:00
|
|
|
elif [ -e /sbin/initctl ]
|
|
|
|
then
|
2017-02-08 14:36:28 +01:00
|
|
|
echo "--> init deamon: upstart"
|
2016-08-20 16:37:45 +02:00
|
|
|
# upstart
|
2016-10-13 21:59:10 +02:00
|
|
|
$HYPERION_RUNNING && initctl stop hyperiond
|
2017-02-08 14:36:28 +01:00
|
|
|
install_file /usr/share/hyperion/service/hyperiond.initctl /etc/init/hyperion.conf && initctl reload-configuration
|
|
|
|
start_msg="--> initctl start hyperiond"
|
|
|
|
initctl start hyperiond
|
2016-05-24 19:56:43 +02:00
|
|
|
|
|
|
|
else
|
2017-02-08 14:36:28 +01:00
|
|
|
echo "--> init deamon: sysV"
|
2016-05-24 19:56:43 +02:00
|
|
|
# sysV
|
2016-10-13 21:59:10 +02:00
|
|
|
$HYPERION_RUNNING && service hyperiond stop 2>/dev/null
|
2017-02-08 14:36:28 +01:00
|
|
|
install_file /usr/share/hyperion/service/hyperion.init /etc/init.d/hyperiond && chmod +x /etc/init.d/hyperiond && update-rc.d hyperiond defaults 98 02
|
|
|
|
start_msg="--> service hyperiond start"
|
|
|
|
service hyperiond start
|
|
|
|
fi
|
|
|
|
|
|
|
|
#cleanup
|
|
|
|
rm -r /usr/share/hyperion/service
|
|
|
|
|
|
|
|
#link binarys and set exec bit
|
|
|
|
BINSP=/usr/share/hyperion/bin
|
|
|
|
BINTP=/usr/bin
|
|
|
|
chmod +x -R $BINSP
|
|
|
|
ln -fs $BINSP/hyperiond $BINTP/hyperiond
|
|
|
|
ln -fs $BINSP/hyperion-remote $BINTP/hyperion-remote
|
|
|
|
ln -fs $BINSP/hyperion-v4l2 $BINTP/hyperion-v4l2
|
|
|
|
ln -fs $BINSP/hyperion-framebuffer $BINTP/hyperion-framebuffer 2>/dev/null
|
|
|
|
ln -fs $BINSP/hyperion-dispmanx $BINTP/hyperion-dispmanx 2>/dev/null
|
|
|
|
ln -fs $BINSP/hyperion-x11 $BINTP/hyperion-x11 2>/dev/null
|
|
|
|
ln -fs $BINSP/hyperion-aml $BINTP/hyperion-aml 2>/dev/null
|
|
|
|
|
|
|
|
|
|
|
|
#Check, if dtparam=spi=on is in place
|
|
|
|
if [ $CPU_RPI -eq 1 ]; then
|
|
|
|
BOOT_DIR="/boot"
|
|
|
|
if [ $BOOT_BERRYBOOT -eq 1 ]; then
|
|
|
|
BOOT_DIR=$(sed -ne "s#/dev/mmcblk0p1 \([^ ]*\) vfat rw,.*#\1#p" /etc/mtab)
|
|
|
|
fi
|
|
|
|
if [ -z "$BOOT_DIR" -o ! -f "$BOOT_DIR/config.txt" ]; then
|
|
|
|
echo '---> Warning: RPi using BERRYBOOT found but can not locate where config.txt is to enable SPI. (BOOT_DIR='"$BOOT_DIR)"
|
|
|
|
SPIOK=1 # Not sure if OK, but don't ask to reboot
|
|
|
|
else
|
|
|
|
SPIOK=`grep '^\dtparam=spi=on' "$BOOT_DIR/config.txt" | wc -l`
|
|
|
|
if [ $SPIOK -ne 1 ]; then
|
|
|
|
echo '---> Raspberry Pi found, but SPI is not set, we write "dtparam=spi=on" to '"$BOOT_DIR/config.txt"
|
|
|
|
sed -i '$a dtparam=spi=on' "$BOOT_DIR/config.txt"
|
|
|
|
REBOOTMESSAGE="echo Please reboot your Raspberry Pi, we inserted dtparam=spi=on to $BOOT_DIR/config.txt"
|
|
|
|
fi
|
|
|
|
fi
|
2016-06-02 19:54:37 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "-----------------------------------------------------------------------------"
|
2017-02-08 14:36:28 +01:00
|
|
|
echo "--> Hyperion has been installed/updated!"
|
|
|
|
echo "--> For configuration, visit with your browser: ${address}"
|
|
|
|
$REBOOTMESSAGE
|
|
|
|
echo "-----------------------------------------------------------------------------"
|
|
|
|
echo "Webpage: www.hyperion-project.org"
|
|
|
|
echo "Wiki: wiki.hyperion-project.org"
|
|
|
|
echo "Forum: forum.hyperion-project.org"
|
2016-06-02 19:54:37 +02:00
|
|
|
echo "-----------------------------------------------------------------------------"
|
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
# try to open the browser for desktops. TODO: add headless detection(?)
|
|
|
|
if [ $CPU_X32X64 -eq 1]
|
|
|
|
echo "--> Will open browser with target: ${address}"
|
|
|
|
if [[ -e /usr/bin/xdg-open ]]
|
|
|
|
then
|
|
|
|
xdg-open http://"$address"
|
|
|
|
elif [[ -e /usr/bin/x-www-browser ]]
|
|
|
|
then
|
|
|
|
x-www-browser http://"$address"
|
|
|
|
elif [[ -e /usr/bin/www-browser ]]
|
|
|
|
then
|
|
|
|
www-browser http://"$address"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2016-06-02 19:54:37 +02:00
|
|
|
if [ -e /opt/hyperion/ ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "---------------------------------------------------------------------------------"
|
|
|
|
echo "- It seemd that you have an older version of hyperion installed in /opt/hyerion -"
|
|
|
|
echo "- please remove it and check your config to avoid problems -"
|
|
|
|
echo "---------------------------------------------------------------------------------"
|
2016-05-24 19:56:43 +02:00
|
|
|
fi
|
|
|
|
|