From fe1d234025f356f46b0e8b85de8b96193c0e95b5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 21 Feb 2019 18:35:08 +0100 Subject: global-functions: add $ScriptLock --- global-functions | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'global-functions') diff --git a/global-functions b/global-functions index b22a295..533e588 100644 --- a/global-functions +++ b/global-functions @@ -187,3 +187,13 @@ :return true; } + +# lock script against multiple invocation +:global ScriptLock do={ + :local Script [ :tostr $1 ]; + + :if ([ / system script job print count-only where script=$Script ] > 1) do={ + :log debug ("Script " . $Script . " started more than once... Aborting."); + :error "Locked." + } +} -- cgit v1.2.3-70-g09d2