1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 02:14:26 +01:00

doorlockd.py: Add lock/unlock scripts

Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
Ralf Ramsauer 2018-03-18 22:03:48 +01:00
parent 8cdf528032
commit 79599e2a45
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,2 @@
- Connect to LDAP
- Add support for post/pre lock/unlock hooks
- Implement proper RS232 support

View File

@ -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):