Change upgrade restart logic to also work on plugins and libs

pull/475/head
Michael Zanetti 2021-10-23 23:37:32 +02:00
parent 432ca3f883
commit 8ec5b4f464
4 changed files with 20 additions and 12 deletions

View File

@ -0,0 +1,7 @@
# nymea hook to restart nymead after upgrades that change nymea plugins or libraries
DPkg::Pre-Install-Pkgs {"/usr/libexec/nymea-upgrade-helper"; };
DPkg::Tools::Options::/usr/libexec/nymea-upgrade-helper::Version "1";
DPkg::Post-Invoke {"if [ -e /tmp/nymea-restart-pending ]; then systemctl restart nymead; rm /tmp/nymea-restart-pending; fi"; };

11
data/dpkg/nymea-upgrade-helper Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
if grep -q nymea
then
systemctl status nymead > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "A nymea package will be changed. Scheduling nymead restart after upgrade."
touch /tmp/nymea-restart-pending
fi
fi

View File

@ -5,3 +5,5 @@ usr/lib/@DEB_HOST_MULTIARCH@/libnymea-core.so.1.0.0
data/systemd/nymead.service /lib/systemd/system/ data/systemd/nymead.service /lib/systemd/system/
data/logrotate/nymead /etc/logrotate.d/ data/logrotate/nymead /etc/logrotate.d/
data/dbus-1/io.guh.nymead.conf /etc/dbus-1/system.d/ data/dbus-1/io.guh.nymead.conf /etc/dbus-1/system.d/
data/dpkg/apt.conf.d/99nymea /etc/apt/apt.conf.d/
data/dpkg/nymea-upgrade-helper /usr/libexec/

View File

@ -29,18 +29,6 @@ else
echo "Failed to set raw socket network capabilities for nymead. Network device discovery will not be available for non root users." echo "Failed to set raw socket network capabilities for nymead. Network device discovery will not be available for non root users."
fi fi
# Restart the nymea daemon after update if it's running
systemctl daemon-reload
systemctl status nymead > /dev/null 2>&1
if [ $? -eq 0 ]; then
systemctl restart nymead
if [ $? -eq 0 ]; then
echo "Successfully restarted nymea daemon."
else
echo "FAILED to restart nymea daemon."
fi
fi
#DEBHELPER# #DEBHELPER#
exit 0 exit 0