From 46bc113c53787c010e8e7fbe3b59b5094ba3e829 Mon Sep 17 00:00:00 2001 From: desertwitch <24509509+desertwitch@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:41:03 +0200 Subject: [PATCH] fix locked files when upgrading live system stop the services before upgrading on a live system to remove any remaining file locks preventing files from getting patched in the running instance (before any reboots). --- plugin/nut-2.8.0.plg | 4 ++++ plugin/nut.plg | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/plugin/nut-2.8.0.plg b/plugin/nut-2.8.0.plg index adbffc89..fb7fe591 100644 --- a/plugin/nut-2.8.0.plg +++ b/plugin/nut-2.8.0.plg @@ -272,6 +272,10 @@ else ln -s /var/run/upsmon.pid /var/run/nut/upsmon.pid fi + # if upgrading on live system, stop the services here + # to release any remaining file locks before patching + [ -x /etc/rc.d/rc.nut ] && /etc/rc.d/rc.nut stop 2>/dev/null + # upgrade plugin package upgradepkg --install-new &plgPATH;/&plgNAME;.txz diff --git a/plugin/nut.plg b/plugin/nut.plg index ac12dc09..08c7d953 100755 --- a/plugin/nut.plg +++ b/plugin/nut.plg @@ -247,6 +247,10 @@ if [ "${sum1:0:32}" != "${sum2:0:32}" ]; then rm &plgPATH;/&plgNAME;.md5 exit 1 else + # if upgrading on live system, stop the services here + # to release any remaining file locks before patching + [ -x /etc/rc.d/rc.nut ] && /etc/rc.d/rc.nut stop 2>/dev/null + # upgrade plugin package upgradepkg --install-new &plgPATH;/&plgNAME;.txz