hyperion.ng/cmake/package-scripts/prerm

70 lines
2.4 KiB
Plaintext
Raw Normal View History

#!/bin/sh
echo "---Hyperion ambient light prerm ---"
UPGRADE="$1"
if [ "$2" = "in-favour" ]; then
# Treat conflict remove as an upgrade.
UPGRADE="upgrade"
fi
# Don't clean-up just for an upgrade.`
2021-11-21 14:26:17 +01:00
if [ "$UPGRADE" = "upgrade" ] ; then
exit 0
fi
# search for users in system, returns first entry
FOUND_USR=`who | grep -o -m1 '^\w*\b'` || "root"
# stop running daemon before we delete it
HYPERION_RUNNING=false
pgrep hyperiond > /dev/null 2>&1 && HYPERION_RUNNING=true
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
$HYPERION_RUNNING && systemctl stop "${CURRENT_SERVICE}" 2> /dev/null
systemctl -q disable "${CURRENT_SERVICE}" 2> /dev/null
else
$HYPERION_RUNNING && systemctl stop hyperion hyperiond"@${FOUND_USR}" hyperion"@${FOUND_USR}" "hyperiond@root" "hyperion@root" 2> /dev/null
systemctl -q disable hyperion hyperiond"@${FOUND_USR}" hyperion"@${FOUND_USR}" "hyperiond@root" "hyperion@root" 2> /dev/null
fi
# disable user specific symlink
2019-01-07 23:33:27 +01:00
echo "---> Disable service and remove entry"
2021-10-05 23:22:19 +02:00
rm -v /etc/systemd/system/hyperion.service /etc/systemd/system/hyperiond@.service /etc/systemd/system/hyperion@.service 2> /dev/null
elif [ -e /sbin/initctl ]
then
# upstart
2021-11-21 14:26:17 +01:00
echo "---> stop init deamon: upstart"
$HYPERION_RUNNING && initctl stop hyperiond
$HYPERION_RUNNING && initctl stop hyperion
2019-01-07 23:33:27 +01:00
echo "---> Remove upstart service"
rm -v /etc/init/hyperion* 2>/dev/null
initctl reload-configuration
else
# sysV
2021-11-21 14:26:17 +01:00
echo "---> stop init deamon: sysV"
2021-10-05 23:22:19 +02:00
$HYPERION_RUNNING && service hyperiond stop 2> /dev/null
$HYPERION_RUNNING && service hyperion stop 2> /dev/null
2019-01-07 23:33:27 +01:00
echo "---> Remove sysV service"
update-rc.d -f hyperion remove
rm /etc/init.d/hyperion* 2>/dev/null
fi
2019-01-07 23:33:27 +01:00
# In case we don't use a service kill all instances
killall hyperiond 2> /dev/null
# delete desktop icons; desktop-file-edit is a workaround to hide the entry and delete it afterwards manual.
# TODO Better way for deletion and keep the desktop in sync without logout/login or desktop dependend cmds?
echo "---> Delete Hyperion desktop icons"
2021-10-05 23:22:19 +02:00
desktop-file-edit --set-key=NoDisplay --set-value=true /usr/share/applications/hyperiond.desktop 2> /dev/null
rm -v /usr/share/applications/hyperion* 2> /dev/null
rm -rv /usr/share/pixmaps/hyperion 2> /dev/null
2019-01-07 23:33:27 +01:00
exit 0