[PATCH 1/2] configurehood: Prevent multiple instances at the same time
robert
rlanghammer at web.de
Mi Okt 31 20:19:36 CET 2018
Hi Adrian,
das wurde ja schon ausreichend diskutiert und sollte auf jeden Fall rein.
Reviewed-by: Robert Langhammer <rlanghammer at web.de>
Am 31.10.18 um 17:35 schrieb Adrian Schmutzler:
> This is based on a similar patch from Tim Niemeyer.
>
> Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
> ---
> src/packages/fff/fff-hoods/Makefile | 2 +-
> src/packages/fff/fff-hoods/files/usr/sbin/configurehood | 8 ++++++++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/src/packages/fff/fff-hoods/Makefile b/src/packages/fff/fff-hoods/Makefile
> index d492572d..5233e611 100644
> --- a/src/packages/fff/fff-hoods/Makefile
> +++ b/src/packages/fff/fff-hoods/Makefile
> @@ -1,7 +1,7 @@
> include $(TOPDIR)/rules.mk
>
> PKG_NAME:=fff-hoods
> -PKG_VERSION:=3
> +PKG_VERSION:=4
> PKG_RELEASE:=1
>
> PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> index 47e228b7..e31ba219 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -1,5 +1,13 @@
> #!/bin/sh
>
> +# 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
> +
> . /usr/share/libubox/jshn.sh
> . /lib/functions/fff/keyxchange
> . /lib/functions/fff/network
Mehr Informationen über die Mailingliste franken-dev