2021-10-02 18:02:52 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
echo "---Hyperion ambient light preinst ---"
|
|
|
|
|
|
|
|
# stop running daemon before we install/upgrade
|
|
|
|
if pgrep hyperiond > /dev/null 2>&1
|
|
|
|
then
|
|
|
|
if grep -m1 systemd /proc/1/comm > /dev/null
|
|
|
|
then
|
|
|
|
# systemd
|
2021-11-21 14:26:17 +01:00
|
|
|
echo "--> stop init deamon: systemd"
|
|
|
|
CURRENT_SERVICE=$(systemctl list-units --all | { grep -o "hyperion*.*\.service" || true; })
|
|
|
|
if [ ! -z ${CURRENT_SERVICE} ]; then
|
|
|
|
systemctl stop "${CURRENT_SERVICE}" 2> /dev/null
|
|
|
|
else
|
|
|
|
FOUND_USR=`who | grep -o -m1 '^\w*\b'` || "root"
|
|
|
|
systemctl stop hyperion hyperiond"@${FOUND_USR}" hyperion"@${FOUND_USR}" "hyperiond@root" "hyperion@root" 2> /dev/null
|
|
|
|
fi
|
2021-10-02 18:02:52 +02:00
|
|
|
elif [ -e /sbin/initctl ]
|
|
|
|
then
|
|
|
|
# upstart
|
2021-11-21 14:26:17 +01:00
|
|
|
echo "--> stop init deamon: upstart"
|
2021-10-02 18:02:52 +02:00
|
|
|
initctl stop hyperiond 2>/dev/null
|
|
|
|
initctl stop hyperion 2>/dev/null
|
|
|
|
else
|
|
|
|
# sysV
|
2021-11-21 14:26:17 +01:00
|
|
|
echo "--> stop init deamon: sysV"
|
2021-10-02 18:02:52 +02:00
|
|
|
service hyperiond stop 2>/dev/null
|
|
|
|
service hyperion stop 2>/dev/null
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# In case we don't use a service kill all instances
|
|
|
|
killall hyperiond 2> /dev/null
|
|
|
|
|
|
|
|
exit 0
|