[PATCH 2/2] nodewatcher: Prevent multiple instances at the same time
Adrian Schmutzler
freifunk at adrianschmutzler.de
Mi Okt 31 17:35:39 CET 2018
This is based on the configurehood-Patch from Tim Niemeyer.
Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
src/packages/fff/fff-nodewatcher/Makefile | 2 +-
src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher | 12 ++++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/packages/fff/fff-nodewatcher/Makefile b/src/packages/fff/fff-nodewatcher/Makefile
index 12ccb0f6..7f989fdb 100644
--- a/src/packages/fff/fff-nodewatcher/Makefile
+++ b/src/packages/fff/fff-nodewatcher/Makefile
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-nodewatcher
-PKG_VERSION:=48
+PKG_VERSION:=49
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
diff --git a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
index c0ae57b8..b0b67e1a 100755
--- a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
+++ b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
@@ -2,10 +2,18 @@
# Netmon Nodewatcher (C) 2010-2012 Freifunk Oldenburg
# License; GPL v3
-SCRIPT_VERSION="48"
-
test -f /tmp/started || exit
+# Allow only one instance
+lockfile="/var/lock/${0##*/}.lock"
+if ! lock -n "$lockfile"; then
+ echo "Only one instance of $0 allowed."
+ exit 1
+fi
+trap "lock -u \"$lockfile\"" INT TERM EXIT
+
+SCRIPT_VERSION="49"
+
#Get the configuration from the uci configuration file
#If it does not exists, then get it from a normal bash file with variables.
if [ -f /etc/config/nodewatcher ];then
--
2.11.0
Mehr Informationen über die Mailingliste franken-dev