[source] sysupgrade: run only one instance at a time.

LEDE Commits lede-commits at lists.infradead.org
Thu May 25 00:22:56 PDT 2017


blogic pushed a commit to source.git, branch master:
https://git.lede-project.org/e96a9a9af82c00dcce606a84a7bb87a00411385d

commit e96a9a9af82c00dcce606a84a7bb87a00411385d
Author: Kenneth Johansson <kenneth.johansson at inteno.se>
AuthorDate: Wed May 24 13:45:37 2017 +0200

    sysupgrade: run only one instance at a time.
    
    Things do not work well if running multiple instances of
    upgrade at the same time.
    
    Signed-off-by: Kenneth Johansson <kenneth.johansson at inteno.se>
---
 package/base-files/files/sbin/sysupgrade | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index c095ca8..1eede14 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -47,6 +47,20 @@ while [ -n "$1" ]; do
 	shift;
 done
 
+# just one instance
+if  ! lock -n /tmp/sysupgrade.lock
+then
+	echo "Another instance of sysupgrade already running"
+	echo "If you are sure this is wrong remove file /tmp/sysupgrade.lock"
+	exit 1
+fi
+
+# make sure the lock is removed when done even when killed
+finish() {
+	lock -u /var/sysupgrade.lock
+}
+trap finish EXIT INT TERM
+
 export CONFFILES=/tmp/sysupgrade.conffiles
 export CONF_TAR=/tmp/sysupgrade.tgz
 



More information about the lede-commits mailing list