From f7725bba5456bb1b4763124268781702c4471e8c Mon Sep 17 00:00:00 2001 From: Ralf Ramsauer Date: Sat, 8 Sep 2018 00:37:21 +0200 Subject: [PATCH] doorlockd: hooks: simplify hooks and add present state Signed-off-by: Ralf Ramsauer --- doorlockd | 28 ++++++++++------------------ share/doorlockd/scripts/post_present | 3 +++ 2 files changed, 13 insertions(+), 18 deletions(-) create mode 100755 share/doorlockd/scripts/post_present diff --git a/doorlockd b/doorlockd index ea64393..5b1bd4d 100755 --- a/doorlockd +++ b/doorlockd @@ -140,14 +140,6 @@ def start_hook(script): Popen(['nohup', join(scripts_prefix, script)]) -def run_lock(): - start_hook('post_lock') - - -def run_unlock(): - start_hook('post_unlock') - - class AuthMethod(Enum): LDAP_USER_PW = 1 @@ -295,7 +287,15 @@ class DoorHandler: return LogicResponse.AlreadyActive self.state = DoorState.Open - run_unlock() + start_hook('post_unlock') + return LogicResponse.Success + + def present(self): + if self.state == DoorState.Present: + return LogicResponse.AlreadyActive + + self.state = DoorState.Present + start_hook('post_present') return LogicResponse.Success def close(self): @@ -304,15 +304,7 @@ class DoorHandler: self.do_close = True self.state = DoorState.Closed - run_lock() - return LogicResponse.Success - - def present(self): - if self.state == DoorState.Present: - return LogicResponse.AlreadyActive - - self.state = DoorState.Present - # new hook? + start_hook('post_lock') return LogicResponse.Success def request(self, state): diff --git a/share/doorlockd/scripts/post_present b/share/doorlockd/scripts/post_present new file mode 100755 index 0000000..8c3cbfc --- /dev/null +++ b/share/doorlockd/scripts/post_present @@ -0,0 +1,3 @@ +#!/bin/bash + +exit 0