mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-11-14 03:15:23 +01:00
doorlockd: hooks: simplify hooks
and add present state Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
4f95021fcf
commit
f7725bba54
28
doorlockd
28
doorlockd
@ -140,14 +140,6 @@ def start_hook(script):
|
|||||||
Popen(['nohup', join(scripts_prefix, script)])
|
Popen(['nohup', join(scripts_prefix, script)])
|
||||||
|
|
||||||
|
|
||||||
def run_lock():
|
|
||||||
start_hook('post_lock')
|
|
||||||
|
|
||||||
|
|
||||||
def run_unlock():
|
|
||||||
start_hook('post_unlock')
|
|
||||||
|
|
||||||
|
|
||||||
class AuthMethod(Enum):
|
class AuthMethod(Enum):
|
||||||
LDAP_USER_PW = 1
|
LDAP_USER_PW = 1
|
||||||
|
|
||||||
@ -295,7 +287,15 @@ class DoorHandler:
|
|||||||
return LogicResponse.AlreadyActive
|
return LogicResponse.AlreadyActive
|
||||||
|
|
||||||
self.state = DoorState.Open
|
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
|
return LogicResponse.Success
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
@ -304,15 +304,7 @@ class DoorHandler:
|
|||||||
|
|
||||||
self.do_close = True
|
self.do_close = True
|
||||||
self.state = DoorState.Closed
|
self.state = DoorState.Closed
|
||||||
run_lock()
|
start_hook('post_lock')
|
||||||
return LogicResponse.Success
|
|
||||||
|
|
||||||
def present(self):
|
|
||||||
if self.state == DoorState.Present:
|
|
||||||
return LogicResponse.AlreadyActive
|
|
||||||
|
|
||||||
self.state = DoorState.Present
|
|
||||||
# new hook?
|
|
||||||
return LogicResponse.Success
|
return LogicResponse.Success
|
||||||
|
|
||||||
def request(self, state):
|
def request(self, state):
|
||||||
|
3
share/doorlockd/scripts/post_present
Executable file
3
share/doorlockd/scripts/post_present
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user