Просмотр исходного кода

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 <[email protected]>
Kenneth Johansson 8 лет назад
Родитель
Сommit
e96a9a9af8
1 измененных файлов с 14 добавлено и 0 удалено
  1. 14 0
      package/base-files/files/sbin/sysupgrade

+ 14 - 0
package/base-files/files/sbin/sysupgrade

@@ -47,6 +47,20 @@ while [ -n "$1" ]; do
 	shift;
 	shift;
 done
 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 CONFFILES=/tmp/sysupgrade.conffiles
 export CONF_TAR=/tmp/sysupgrade.tgz
 export CONF_TAR=/tmp/sysupgrade.tgz