2016-05-24 19:56:43 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
install_file()
|
|
|
|
{
|
|
|
|
src="$1"
|
|
|
|
dest="$2"
|
|
|
|
|
|
|
|
if [ -e "$dest" ] && ! cmp --quiet "$src" "$dest"
|
|
|
|
then
|
2016-06-02 19:54:37 +02:00
|
|
|
echo "INFO: $dest exists, new version copied to ${dest}.new"
|
2016-05-24 19:56:43 +02:00
|
|
|
cp "$src" "${dest}.new"
|
2016-06-02 19:54:37 +02:00
|
|
|
return 1
|
2016-05-24 19:56:43 +02:00
|
|
|
fi
|
2016-06-02 19:54:37 +02:00
|
|
|
|
|
|
|
cp "$src" "${dest}"
|
|
|
|
return 0
|
2016-05-24 19:56:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-09-17 00:40:29 +02:00
|
|
|
if [ ! -e "/etc/hyperion/hyperion.config.json" ]
|
|
|
|
then
|
|
|
|
echo "install default config to /etc/hyperion"
|
|
|
|
/usr/bin/hyperiond --export-config /etc/hyperion/hyperion.config.json
|
|
|
|
fi
|
2016-05-24 19:56:43 +02:00
|
|
|
|
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
|
|
|
|
echo "- init deamon: systemd"
|
2016-05-24 19:56:43 +02:00
|
|
|
# systemd
|
2016-06-02 19:54:37 +02:00
|
|
|
$HYPERION_RUNNING && systemctl stop hyperion 2> /dev/null
|
|
|
|
install_file /usr/share/hyperion/service/hyperion.systemd.sh /etc/systemd/system/hyperion.service || SERVICE_POSTFIX=".new"
|
2016-05-24 19:56:43 +02:00
|
|
|
systemctl -q enable hyperion.service
|
2016-06-02 19:54:37 +02:00
|
|
|
start_msg="systemctl start hyperion"
|
|
|
|
$HYPERION_RUNNING && systemctl start hyperion
|
|
|
|
|
2016-08-20 16:37:45 +02:00
|
|
|
elif [ -e /sbin/initctl ]
|
|
|
|
then
|
|
|
|
echo "- init deamon: upstart"
|
|
|
|
# upstart
|
|
|
|
$HYPERION_RUNNING && initctl stop hyperion
|
|
|
|
install_file /usr/share/hyperion/service/hyperion.initctl.sh /etc/init/hyperion.conf || SERVICE_POSTFIX=".new"
|
|
|
|
initctl reload-configuration
|
|
|
|
start_msg="initctl start hyperion"
|
|
|
|
$HYPERION_RUNNING && initctl start hyperion
|
2016-05-24 19:56:43 +02:00
|
|
|
|
|
|
|
else
|
2016-06-02 19:54:37 +02:00
|
|
|
echo "- init deamon: sysV"
|
2016-05-24 19:56:43 +02:00
|
|
|
# sysV
|
2016-06-02 19:54:37 +02:00
|
|
|
$HYPERION_RUNNING && service hyperion stop 2>/dev/null
|
|
|
|
install_file /usr/share/hyperion/service/hyperion.init.sh /etc/init.d/hyperion || SERVICE_POSTFIX=".new"
|
2016-05-24 19:56:43 +02:00
|
|
|
chmod +x /etc/init.d/hyperion
|
|
|
|
update-rc.d hyperion defaults 98 02
|
2016-06-02 19:54:37 +02:00
|
|
|
start_msg="service hyperion start"
|
|
|
|
$HYPERION_RUNNING && service hyperion start
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "-----------------------------------------------------------------------------"
|
|
|
|
echo "- hyperion is installed, please check your configuration in /etc/hyperion/ -"
|
|
|
|
echo "-----------------------------------------------------------------------------"
|
|
|
|
|
|
|
|
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
|
|
|
|
|