diff options
Diffstat (limited to 'recipes-connectivity/lora/lora-network-server')
-rwxr-xr-x | recipes-connectivity/lora/lora-network-server/lora-network-server.init | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/recipes-connectivity/lora/lora-network-server/lora-network-server.init b/recipes-connectivity/lora/lora-network-server/lora-network-server.init index 9dc8f7a..032a0f7 100755 --- a/recipes-connectivity/lora/lora-network-server/lora-network-server.init +++ b/recipes-connectivity/lora/lora-network-server/lora-network-server.init @@ -2,6 +2,7 @@ NAME="lora-network-server" +LOCK="/var/lock/$NAME" ENABLED="yes" @@ -147,17 +148,35 @@ if [ "$ENABLED" != "yes" ]; then exit fi +force_stop() { + do_stop + rm -fr $LOCK +} + +function try_lock() { + if mkdir $LOCK; then + trap "rm -fr $LOCK" EXIT + else + echo "Lora Network Server lock not acquired, resource in use" + exit 1 + fi +} + + + case "$1" in "start") + try_lock do_start ;; "stop") - do_stop + force_stop ;; "restart") ## Stop the service and regardless of whether it was ## running or not, start it again. + try_lock do_stop do_start ;; |