mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 10:24:26 +01:00
doorlockd.py: Add lock/unlock scripts
Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
8cdf528032
commit
79599e2a45
@ -1,3 +1,2 @@
|
||||
- Connect to LDAP
|
||||
- Add support for post/pre lock/unlock hooks
|
||||
- Implement proper RS232 support
|
||||
|
@ -23,6 +23,7 @@ import sys
|
||||
from enum import Enum
|
||||
from random import sample
|
||||
from serial import Serial
|
||||
from subprocess import Popen
|
||||
from threading import Thread
|
||||
from time import sleep
|
||||
|
||||
@ -87,6 +88,14 @@ def choose_insult():
|
||||
return(sample(eperm_insults, 1)[0])
|
||||
|
||||
|
||||
def start_hook(script):
|
||||
if simulate:
|
||||
log.info('Simulation mode: not starting %s' % script)
|
||||
return
|
||||
log.info('Starting hook %s' % script)
|
||||
Popen(['nohup', script])
|
||||
|
||||
|
||||
class AuthMethod(Enum):
|
||||
LDAP_USER_PW = 1
|
||||
|
||||
@ -165,6 +174,7 @@ class DoorHandler:
|
||||
return LogicResponse.AlreadyOpen
|
||||
|
||||
self.state = DoorState.Open
|
||||
start_hook('./scripts/post_unlock.sh')
|
||||
return LogicResponse.Success
|
||||
|
||||
def close(self):
|
||||
@ -172,6 +182,7 @@ class DoorHandler:
|
||||
return LogicResponse.AlreadyLocked
|
||||
|
||||
self.state = DoorState.Close
|
||||
start_hook('./scripts/post_lock.sh')
|
||||
return LogicResponse.Success
|
||||
|
||||
def request(self, state):
|
||||
|
Loading…
Reference in New Issue
Block a user