diff --git a/data/dpkg/apt.conf.d/99nymea b/data/dpkg/apt.conf.d/99nymea new file mode 100644 index 00000000..d85a9b2f --- /dev/null +++ b/data/dpkg/apt.conf.d/99nymea @@ -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"; }; + diff --git a/data/dpkg/nymea-upgrade-helper b/data/dpkg/nymea-upgrade-helper new file mode 100755 index 00000000..b641bf12 --- /dev/null +++ b/data/dpkg/nymea-upgrade-helper @@ -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 diff --git a/debian/nymead.install.in b/debian/nymead.install.in index 672a4bd3..2fe928e4 100644 --- a/debian/nymead.install.in +++ b/debian/nymead.install.in @@ -5,3 +5,5 @@ usr/lib/@DEB_HOST_MULTIARCH@/libnymea-core.so.1.0.0 data/systemd/nymead.service /lib/systemd/system/ data/logrotate/nymead /etc/logrotate.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/ diff --git a/debian/nymead.postinst b/debian/nymead.postinst index faf9f178..9aeb59f6 100755 --- a/debian/nymead.postinst +++ b/debian/nymead.postinst @@ -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." 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# exit 0